# Answer to Question #60048 in C++ for sajid

Question #60048

Q. Write a program that counts the number of 0, odd or even number.

Expert's answer

#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;

}

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 orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment