Skip to content

Commit cfeb18a

Browse files
Ler 3 valores e dize o maio com funções
1 parent 627857c commit cfeb18a

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

desafios_em_c/desafio17.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// leia três valores do teclado e diga qual
2+
// é maior
3+
// função para leitura de valores e para
4+
// análise de qual é maior
5+
// COM FUNÇÕES
6+
7+
8+
#include <stdio.h>
9+
10+
int leNumero() {
11+
int numero;
12+
13+
printf("Digite um numero: ");
14+
scanf("%d", &numero);
15+
16+
return numero;
17+
}
18+
19+
int compara(int a, int b, int c) {
20+
int maior;
21+
22+
maior = a;
23+
if (b > maior)
24+
maior = b;
25+
if (c > maior)
26+
maior = c;
27+
28+
return maior;
29+
}
30+
31+
int main() {
32+
33+
int a, b, c, maior;
34+
35+
a = leNumero();
36+
b = leNumero();
37+
c = leNumero();
38+
39+
maior = compara(a, b, c);
40+
41+
printf("Maior numero: %d", maior);
42+
43+
return 0;
44+
}

0 commit comments

Comments
 (0)