Answer to Question #60048 in C++ for sajid
Q. Write a program that counts the number of 0, odd or even number.
1
2016-05-24T11:51:02-0400
#include <iostream>
int main()
{
int number, odd=0, even=0, zeros=0;
std::cout << "Enter numbers (111111 - the end of input)\n";
do{
std::cin>>number;
if(number==0) zeros++;
else if (number % 2) odd++;
else even++;
}while (number!=111111);
std::cout << "\nNumber of 0: " <<zeros
<< "\nNumber of odd numbers (without 111111): "<< --odd
<< "\nNumber of even number: "<< even;
return 0;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++
Comments
Leave a comment