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
Which subunit of a heterodimeric cdk is the regulatory subunit?
Lemur [1.5K]
The answer is cyclin subunit
8 0
2 years ago
Hurry plz
Elanso [62]

Answer: It allows you to locate materials, be aware of your assignments and plan time to get things done.

Hope it helped.

3 0
3 years ago
A web designer is creating a web site and wants each browser to resize the text size to look the same in each device. what measu
adelina 88 [10]
The designer could use the measurements in pixels. 
4 0
3 years ago
Which of the following is the largest unit of information?
Mila [183]
What are the choices?

5 0
3 years ago
Read 2 more answers
As you apply to college when should you apply for financial aid
Nataliya [291]

Answer:

after you are accepted in the college

Explanation:

You should apply for admission to the colleges you are interested in BEFORE filing your FAFSA. Once you are accepted to the colleges you have applied to, you can add those schools to receive financial aid award offers from when you file your FAFSA.

4 0
3 years ago
Other questions:
  • Put the steps of the decision-making process in the correct order.
    12·1 answer
  • A potential threat to administrators’ ability to manage the correctional system is
    12·1 answer
  • This program will read integers from a file and find results from these integers. Open the file, test to make sure the file open
    12·1 answer
  • Question 4 / 5
    11·1 answer
  • Web browsers are used to browse the world wide web.
    5·2 answers
  • Write an application that instantiates five Recording objects and prompts the user for values for the data fields. Then prompt t
    13·1 answer
  • What is the limitation of computer<br>​
    5·1 answer
  • Two girls were born to the same mother, on the same day, at the same time, in the same month and the same year and yet they're n
    7·1 answer
  • We can improve our knowledge and skills on animals and fish raising with the use of internet​
    15·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!