Can't figure out a for statement that will make this function please ASAP
Receives nothing from main
Returns an even integer
Ask the user for an even integer
Read in the user’s input value.
Repeat the prompt and input for any invalid numbers until a value
of the correct type is entered.
Return the legal input value.

Recommended Answers

All 2 Replies

something like

int number = some_odd_number;
for( ;number_is_odd; ) {
     asks input;
     store input in number;
returns number;


cout << "Enter an even integer: ";
cin >> number;
while (number < 0 )
cout << "Enter an even integer:";
cin >> number;
if (number % 2 == 0)
...your number is even
your number is odd......

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.