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
___________ is some danger that can exploit a vulnerability.
andreyandreev [35.5K]

<u>Threat </u>is some danger that can exploit a vulnerability.

<h3>What is Threat?</h3>

Threat  is seen as Anything that can be able to take advantage of a vulnerability, intentionally as well as  accidentally, and take or damage, the  asset of a person.

Note that a threat is that which a person or firm is protect against and Vulnerability is seen as Weaknesses.

Therefore, <u>Threat </u>is some danger that can exploit a vulnerability.

Learn more about vulnerability from

brainly.com/question/25633298

#SPJ1

8 0
2 years ago
Which section of a personal narrative requires the most development
attashe74 [19]
D. Plot because a,b,and c is consider plot can i have brainlest answer please

5 0
4 years ago
What is the role of consumers in determining what is produced in a market economy
gregori [183]

Consumer preferences and resource scarcity determine which goods are produced and in what quantity; the prices in a market economy act as signals to producers and consumers who use these price signals to help make decisions.

(i got this from google btw)

hope this helped :) pls give branliest

3 0
4 years ago
Read 2 more answers
How do you flatten a 2D array to become a 1D array in Java?
Leni [432]

Answer:

With Guava, you can use either

int[] all = Ints.concat(originalArray);

or

int[] all = Ints.concat(a, b, c);

Explanation:

Use GUAVA

4 0
2 years ago
Draw a full binary tree of height 2. How many nodes does it have?
Paraphin [41]

Answer:

The number of nodes in a full binary tree of height 2 = 7

Explanation:

At each level k, of the full binary tree there are usually 2^{k} \\ nodes.

So the full binary tree of height 2 has nodes= 2^{0} \\ + 2^{1} \\ + 2^{2} \\.

which is 7.

6 0
4 years ago
Other questions:
  • Some people are unable to arrange six matches to form four equilateral triangles because they fail to consider a three - dimensi
    6·1 answer
  • Binary code what does this mean I was sick so I don't under stand
    7·2 answers
  • Which option can Jesse use to customize her company’s logo, name, address, and similar details in all her business documents?
    6·1 answer
  • a limited-access expressway. A)allows vehicles to enter or exit only at certain place.B) does not permit trucks or buses.C)has n
    9·1 answer
  • Which kind of testing runs the system in a simulated environment using simulated data?a) validation testing. b) verification tes
    5·1 answer
  • Which of the following is a negative effect of the rise in agricultural technology following World War II?
    5·1 answer
  • What Temperature does mainframe need
    15·2 answers
  • Attach 2 screen shots demonstrating an understanding of file management tools, such as keyboard shortcuts, copy, paste, delete,
    8·1 answer
  • Hamilton is the best
    12·1 answer
  • How would you reply to an email message you've received that has multiple recipients, all of whom you would like to see your rep
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!