answersLogoWhite

0

#include

#include

unsigned input_num(std::string prompt)

{

unsigned num = 0;

while (1)

{

std::cout<

std::string input="";

getline (std::cin, input);

std::stringstream ss (input);

if (ss>>num)

break;

std::cout<<"Invalid input.\n";

}

return (num);

}

int main()

{

unsigned nums = input_num ("How many numbers would you like to input? (0 to exit)");

unsigned odds = 0;

while (nums--)

{

unsigned num = input_num ("Please enter a number");

if (num%2)

++odds;

}

std::cout<<"\nYou entered "<

}

Example output

How many numbers would you like to input? (0 to exit): 10

Please enter a number: 0

Please enter a number: 1

Please enter a number: 2

Please enter a number: 3

Please enter a number: 4

Please enter a number: 5

Please enter a number: 6

Please enter a number: 7

Please enter a number: 8

Please enter a number: 9

You entered 5 odd numbers.

User Avatar

Wiki User

11y ago

What else can I help you with?

Related Questions

Program to count the number of numbers in an array using 8085 microprocessor?

A program which is used to count the number of numbers in an array using a 8085 microprocessor is known as a assembly language program.


How much does one have to pay calling a 1800 number?

No the charge is reversed to the owner of the number.


How is the number of factors of square numbers different from the number of factors for other numbers?

Square numbers have an odd number of factors.


What do different elements have different numbers of?

Different elements have different numbers of protons. The number of protons identifies the element.


Do isotopes have the same atomic number and different mass numbers?

Yes. Isotopes have the same atomic number because all of their atoms have the same number of protons. They have different mass numbers because their atoms have different numbers of neutrons, and mass number is the sum of the numbers of protons and neutrons.


What is a distinct number?

it is different numbers


What is an isotone?

An isotone is a group of atomic nuclei that have the same neutron number but different atomic numbers. This means isotones have the same number of neutrons but different numbers of protons. Isotones are different from isotopes, which have the same atomic number but different numbers of neutrons.


What is the least number that is divisible by four different prime numbers?

the least number is 210 which is divisible by four different prime numbers.


A program c plus plus on automorphic numbers or not?

how to write a program that counts automorphic number from 1 to 999


How can different atoms of the same element have the same atomic number but can have different mass numbers?

They have different numbers of neutrons.


Which number has an odd number of different factors?

All square numbers have an odd number of factors.


Do atoms of the same number have a different mass number?

Atoms of the same atomic number (= number of protons in each nucleus) can have different mass numbers because of containing different numbers of neutrons in each atom.