-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContando.valores..c
More file actions
92 lines (83 loc) · 2.24 KB
/
Copy pathContando.valores..c
File metadata and controls
92 lines (83 loc) · 2.24 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[])
{ setlocale(LC_ALL,"Portuguese");
/* Escreva um programa em c que lê 5 números inteiros, um por vez.
Conte quantos destes valores são negativos e positivos;
ao final, imprimir na tela a quantidade dos negativos e positivos
*/
/*int um,dois,tres,quatro,cinco,positivos = 0,negativos = 0;
printf("Digite o primeiro valor:");
scanf("%d",&um);
printf("Digite o segundo valor:");
scanf("%d",&dois);
printf("Digite o terceiro valor:");
scanf("%d",&tres);
printf("Digite o quarto valor:");
scanf("%d",&quatro);
printf("Digite o quinto valor:");
scanf("%d",&cinco);
if(um < 0)
negativos++; // negativos +=1; negativos =negativos + 1 . vai somar mais um//
else
positivos++;
if(dois < 0)
negativos++;
else
positivos++;
if(tres < 0)
negativos++;
else
positivos++;
if(tres < 0)
negativos++;
else
positivos++;
if(quatro < 0)
negativos++;
else
positivos++;
if(cinco < 0)
negativos++;
else
positivos++;
printf("\nPositivos: %d\nNegativos:%d\n",positivos,negativos);
*/
// 2 versão //
// com variável VALOR somente //
int valor,positivos = 0,negativos = 0;
printf("Digite o primeiro valor:");
scanf("%d",&valor);
if(valor < 0)
negativos++; // negativos +=1; negativos =negativos + 1 . vai somar mais um//
else
positivos++;
printf("Digite o segundo valor:");
scanf("%d",&valor);
if(valor < 0)
negativos++; // negativos +=1; negativos =negativos + 1 . vai somar mais um//
else
positivos++;
printf("Digite o terceiro valor:");
scanf("%d",&valor);
if(valor < 0)
negativos++; // negativos +=1; negativos =negativos + 1 . vai somar mais um//
else
positivos++;
printf("Digite o quarto valor:");
scanf("%d",&valor);
if(valor < 0)
negativos++; // negativos +=1; negativos =negativos + 1 . vai somar mais um//
else
positivos++;
printf("Digite o quinto valor:");
scanf("%d",&valor);
if(valor < 0)
negativos++; // negativos +=1; negativos =negativos + 1 . vai somar mais um//
else
positivos++;
printf("\nPositivos: %d\nNegativos:%d\n",positivos,negativos);
return 0;
}