Busco ayuda con mi código
Publicado por miguel (1 intervención) el 01/05/2020 17:06:49
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
//el problema es está cuando ingreso ingreso un numero para, la expresión"hay alguna persona que ingreso un numero par, volver a repetir" sigue saliendo a pesar de colocar solamente números impares.
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<windows.h>
int main()
{
srand(time(NULL));
int n;
int c=0;
int alea = rand()%(5-2+1)+2;
while(1)
{
printf("\nSe pedira a %i personas que ingrese un numero",alea);
for(int i=1;i<=alea;i++)
{
printf("\nIngrese un numero: ");
scanf(" %i",&n);
if((n%2)==0)
{
c = c+n;
}
}
if(c==0)
{
printf("todas las personas ingresaron numeros impares, proceso terminado");
break;
}
else if((c%2)==0)
{
printf("\nhay alguna persona que ingreso un numero par, volver a repetir\n");
}
}
}
Valora esta pregunta


0