6
Statement - Make an algorithm that reads a set of numbers (X) and indicate the amount of even numbers (Qpares) and the amount of odd numbers (Qimpares) read.
Note: Entering values ends when the user inserts 0.
#include <stdio.h>
main(){
int num,res,qpar=0,qimp=0;
while(num!=0){
printf("Introduza");
scanf("%d",&num);
res=num%2;
if(res==0){
qpar++;
} else {
qimp++;
}
}
printf("Pares -> %d\n",&qpar);
printf("Impares -> %d\n",&qimp);
}
I don’t know what I’m doing wrong here, it compiles well but the problem is it doesn’t give me the right values of even and odd numbers. Otherwise it is also making the cycle correctly.
I removed & from my code and stopped cycling... but your code is working perfectly.
– Nope Nope