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
After reading passage “the incredible machine” why do you think the article has been titled so?
Vitek1552 [10]
I haven’t read it, but just by the title it was probably talking about an incredible machine that was new to people.
7 0
3 years ago
What is the difference between a switch and a hub?
marta [7]

Explanation:

A hub is used to send the message from one port to other ports.It does not know the specific address of the destination where the message needs to send.it works on Physical layer of the OSI model(layer 1).

A switch can handle data and it knows the specific address of the destination.A switch works on the data link Layer of the OSI model(layer 2).

8 0
3 years ago
What are the total number of rows and columns on a worksheet?.
Margaret [11]

Answer:

1,048,576 rows

Explanation:

hahha cause im smart

3 0
2 years ago
Read 2 more answers
Which of the following is an advantage of text HTML editors over plain text editors?
zubka84 [21]
C hope that helps have a good day and I feel you good for big hugs
5 0
3 years ago
Read 2 more answers
Point mode allows you to select cells for use in a formula by using your finger or the pointer
Serga [27]
That statement is true

in excel, you could enter point mode by pressing any keyboard navigation such as page down, page up, or the arrow keys or by clicking any cells in the worksheet

This mode will select a cell or range as formula operand


7 0
3 years ago
Other questions:
  • Which of the following terms means that the system changes based on
    14·1 answer
  • ANSWER ME PLS
    9·1 answer
  • Why does a satellite requires two bridges?
    11·1 answer
  • An identifying value called a/an ____ is assigned by the java runtime to an object when it is created, to allow the java runtime
    14·1 answer
  • What is the trickiest time of the day to drive? A. Early morning B. Late night C. After the sun sets
    8·2 answers
  • What will be displayed if the following Java code segment is run? System.out.println("one "); System.out.print("two "); System.o
    12·1 answer
  • If you can name this you get 15 points: ↑↑↓↓←→←→βα
    10·1 answer
  • Explain how you think robotics plays a part in the subway driver's job.
    13·2 answers
  • Which two peripherals are not required to browse the internet?
    8·1 answer
  • Wight an essay on Knowledge sharing among robots.<br> please and please do not delete my question.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!