-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
66 lines (52 loc) · 1.48 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
typedef struct {
float x;
float y;
} Coordenadas;
void somar (Coordenadas *c1, float valor) {
c1->x = c1->x + valor;
c1->y = c1->y + valor;
printf("Adição dos valores com %.2f.\n", valor);
}
void subtrair (Coordenadas *c1, float valor) {
c1->x = c1->x - valor;
c1->y = c1->y - valor;
printf("Subtração dos valores com %.2f.\n", valor);
}
void multiplicar (Coordenadas *c1, float valor) {
c1->x = c1->x * valor;
c1->y = c1->y * valor;
printf("Multiplicação dos valores com %.2f.\n", valor);
}
void dividir (Coordenadas *c1, float valor) {
c1->x = c1->x / valor;
c1->y = c1->y / valor;
printf("Divisão dos valores com %.2f.\n", valor);
}
int main()
{
setlocale(LC_ALL, "portuguese");
Coordenadas c1;
c1.x = 18;
c1.y = 32;
printf("CORD1 = [%.2f, %.2f]\n\n", c1.x, c1.y);
somar(&c1, 7);
printf("CORD1 = [%.2f, %.2f]\n", c1.x, c1.y);
somar(&c1, 22);
printf("CORD1 = [%.2f, %.2f]\n\n", c1.x, c1.y);
subtrair(&c1, 61);
printf("CORD1 = [%.2f, %.2f]\n", c1.x, c1.y);
subtrair(&c1, 20);
printf("CORD1 = [%.2f, %.2f]\n\n", c1.x, c1.y);
multiplicar(&c1, 5);
printf("CORD1 = [%.2f, %.2f]\n", c1.x, c1.y);
multiplicar(&c1, 0.5);
printf("CORD1 = [%.2f, %.2f]\n\n", c1.x, c1.y);
dividir(&c1, 2);
printf("CORD1 = [%.2f, %.2f]\n", c1.x, c1.y);
dividir(&c1, 5);
printf("CORD1 = [%.2f, %.2f]\n", c1.x, c1.y);
return 0;
}