This is the description of the prac im doing. The code below is what I have come up so far. I also attached the pseudocode as well. And for me it's confusing somehow. However, I'm wanting to ask that how to use a while loop to force odd even number.
Write a program that prints all the odd or even integers between any two integers (inclusive) entered by the user. The user should be able to select whether odd or even integers are to be printed.
Use a while loop to force correct entry for the odd/even choice (use type char for choice).
The program should determine which is the smaller of the two integers entered. If the second integer is smaller, then swap – but do NOT use the swap() function. Pass the numbers and your choice of odd or even to a function.
Your code should contain the odd/even conditional statements before a while loop, and use a loop increment of two, looping from the smaller number towards the larger number. This code should be in a separate function, not in main().
Prompt and read first integer
Prompt and read second integer
If second integer is smaller
Swap (do NOT use the swap() function)
Prompt and read choice of even or odd
Invoke foo() to print
If (num1 is odd and choice is even) or (num1 is even and choice is odd)
Add 1 to num1
Print all even or odd (as per choice) from num1 to num2 (inclusive)
int remainder = 1;
cout << "Please enter the first integer: ";
cin >> number;
cout << "Please enter the second integer: ";
cin >> number;
while ( choice )
if ( number % 2 == 0)
cout << "\t\t " << number << " is even.\n";
cout << "\t\t " << number << " is odd.\n";