1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
elena55 [62]
3 years ago
5

Write a program segment with a do-while loop that displays whether a user-entered integer is even or odd. The code should then a

sk the user if he or she wants to test another number. The loop should repeat as long as the user enters 'Y' or 'y' . Use a logical OR operator in the do-while loop test expression
Computers and Technology
1 answer:
Leya [2.2K]3 years ago
5 0

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 .
You might be interested in
Why aren’t I leveling up? I have enough points and even a brainliest. Could an expert please help me!! I am really confused.
svlad2 [7]
This actually happened to me when I was supposed to be an expert. Answer one more question, log out and back in, and then you should be the next rank!
Hope this helps! Have a happy holiday!
8 0
3 years ago
Which option best describes the game Farmville? It is designed to educate players about virtual currencies. It is designed to ed
Levart [38]
The answer would be <span>It is designed to promote social interaction and community building.</span>
7 0
3 years ago
Read 2 more answers
The sum of these 9 numbers is 36. 2, 2, 6, 2, 1, 8, 7, 5, 3 What is the mean of these 9 numbers?
fiasKO [112]

Answer:

4

Explanation:

The mean is the sum divided by the count of numbers, so 36/9 = 4

6 0
2 years ago
Read 2 more answers
What is another name for a blue screen error which occurs when processes running in kernel mode encouter a problem and windows m
Sonbull [250]
Another name for a blue screen error is Blue screen of death
7 0
3 years ago
What is required when opening a checking account?
Brums [2.3K]
A, because if not, there is nothing to say it exsists
8 0
3 years ago
Read 2 more answers
Other questions:
  • Dominick has been hired to design a network for Pirate Press. In a paragraph of no less than 125 words, discuss what he needs to
    12·2 answers
  • What action makes RAM on your computer disappear?
    12·2 answers
  • Need Help !!! Please
    8·1 answer
  • The faster alcohol is consumed, the faster it reaches the __________.
    9·2 answers
  • The numbers on the bottom of a typical check represent all of the following EXCEPT
    14·1 answer
  • Anyone watch anime, i love stay kids and they sang the op for Tower of God XD
    8·2 answers
  • The Scientific Method is a/an
    9·2 answers
  • How do you get off of the comments after you look at them wit out going all the way off the app?
    15·1 answer
  • If we need to manage a contiguous range of memory, handling requests to allocate various sized chunks, and later make those chun
    12·1 answer
  • Ndcdeviceid?????????????????????​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!