Answer:
Following is the program in C++ program
#include<iostream> // header file
using namespace std; // namespace
int main() // main function
{
int num1 = 0; // variable declaration
char test;// variable declaration
do
{
cout << " Enter the number: ";
cin >> num1; //Read the input by the user
if (num1 % 2 == 0) // check the condition of even
cout << " number is even.\n";
else // check the condition of odd
cout << "Number is odd.\n";
cout << " Do you wanted the another test of number (y/n)? ";
cin >> test; //Read the input by user
} while (test == 'y' || test == 'Y'); //terating the loop
return 0;
}
Output:
Enter the number:45
number is even.
Do you wanted the another test of number (y/n) Y
Enter the number:5
Number is odd.
Do you wanted the another test of number (y/n) n
Explanation:
Following are the description of program
- Declared a variable "num1" as integer type and initialized as 0 to them
- Declared a variable "test" as char type .
- After that iterating the do -while loop .Read the value by the user in the "num1" variable .
- Check the condition of even and odd by using % operator .
- Read the value of test by the user .If the user enter Y or y then loop again executing otherwise not .