Ask your own question, for FREE!
Computer Science 12 Online
OpenStudy (rocklionmba):

(C) Need help with some code Write a loop that reads positive integers from standard input and that terminates when it reads an integer that is not positive. After the loop terminates , it prints out the sum of all the even integers read and the sum of all the odd integers read. Declare any variables that are needed.

OpenStudy (rocklionmba):

Currently, I have this: int readnum; int evennum; int oddnum; while(scanf("%d", &readnum) > 0){ if (readnum % 2 == 0){ evennum += readnum; } else { oddnum +=readnum; } } printf("%d %d", evennum, oddnum);

OpenStudy (rocklionmba):

The only thing myprogramminglab is complaning about is evennum, it comes out always 10 less than it should be and I have no idea what exactly is wrong

OpenStudy (karim728):

you have to initialize evennum, evennum

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Arriyanalol: i need help
22 hours ago 7 Replies 1 Medal
Arriyanalol: CONGRATS to me
1 day ago 8 Replies 2 Medals
Legomaster346: What colleges are good that are near Arab Alabama?
1 week ago 5 Replies 0 Medals
Arriyanalol: i need help
1 week ago 6 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!