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
frosja888 [35]
3 years ago
8

Write an application that asks a user to type an even number or the sentinel value 999 to stop. When the user types an even numb

er, display the message "Good job!" and then ask for another input. When the user types an odd number, display an error message, "x is not an even number", and then ask for another input. When the user types the sentinel value 999, end the program
Computers and Technology
2 answers:
Alisiya [41]3 years ago
6 0

Answer:

int value;

while(1){

scanf("%d\n", &value);

if(value == 999)

break;

if(value%2 == 0)

printf("Good job");

else if(value%2 == 1)

printf("%d is not an even number", value);

}

Explanation:

I am going to write a C code for this.

The while(1) runs until the break command. So

int value;

while(1){

scanf("%d\n", &value);

if(value == 999)

break;

if(value%2 == 0)

printf("Good job");

else if(value%2 == 1)

printf("%d is not an even number", value);

}

yan [13]3 years ago
3 0

Answer:

 do{

    std::cout << "input an even number: ";

    std::cin >> n;

    even=n%2;

    if (even==0)

    std::cout << "Good job!\n";

    else

    std::cout << n <<" is not an even number\n";

    }while(n!=999);

Explanation:

#include <iostream>

#include <string>

int main()

{ int n=0,even;

 do{

    std::cout << "input an even number: ";  //print on screen to input the number

    std::cin >> n;  //put that value on n variable

    even=n%2;

    if (even==0)  //if even is zero the number is even

    std::cout << "Good job!\n";

    else  //if even is not zero the number is odd

    std::cout << n <<" is not an even number\n";

    }while(n!=999);  // we will repeat the proccess while n is diffrente from 999

}

You might be interested in
When do you use a for loop instead of a while loop? (There may be more than one answer.)
statuscvo [17]

Answer:

- You know how many times you want the loop to run.

- When there is a defined start and end.

Explanation:

Required:

When to use for instead of while loop?

First, it should be noted that both for loop and while loop are used for iteration. However, depending on the scenario; there is preference on one to the other.

The basic syntax of for loop is:

for(start;end;condition)\{\}

<em>The condition could either be increment or decrement</em>

The basic syntax of while loop is:

while(condition)\{\}

<em>The condition could be any condition whatsoever</em>

Analyzing the options one after the other.

1. How many times the loop to run.

The for loop is preferred here because of the simplicity of the for loop.

2. & 3. Both the for and while loops are used for code repetition and to perform number calculations

4. Defined start and end.

From the syntax of the for loop

for(start;end;condition)\{\}

<em />

A for loop has a definite start and end in its basic syntax and is more preferable to use instead of a while loop.

<em />

<em />

Hence, 1 & 4 answer the question

8 0
2 years ago
What are the five types of alignment in word?
valentinak56 [21]
I know of four,
Left-aligned
Center-aligned
right-aligned
justified

5 0
3 years ago
Read 2 more answers
$8.25/hour; _____$/year, when working 40 hours a week.
Katarina [22]
If you work 50 weeks/year and 40 hours/week, you will make 16,500 dollars per year if you make 8.25 per hour
8 0
3 years ago
An electric kettle has the resistance of 30ohms what will flow when it connected to a 240v supply... find also the power rating
SVEN [57.7K]

Answer:

Power = 1920 Watts or 1.92 Kilowatts

Explanation:

Given the following data;

Resistance = 30 Ohms

Voltage = 240 Volts

To find power rating of the kettle;

Mathematically, the power consumption of an electric device is given by the formula;

Power = voltage²/resistance

Substituting into the formula, we have;

Power = 240²/30

Power = 57600/30

Power = 1920 Watts or 1.92 Kilowatts

4 0
3 years ago
How can this requirement be met? Universal Containers provide access to Salesforce for their Sales, Service and Marketing Teams.
ArbitrLikvidat [17]
Good luck and I hope u can find the right answer
5 0
3 years ago
Other questions:
  • Larry does not want to save his Internet browsing details on his computer what files delete to clear his information from the co
    7·1 answer
  • Soo...My Old 3DS XL haven't been touched in around a year...So i tried to charge it but no LED lights opened..Even the power but
    14·1 answer
  • What is an apprenticeship
    7·1 answer
  • Which of the following branches of government is NOT involved in Discretionary Fiscal Policy?
    8·1 answer
  • Describe the positive and negative effects of Internet​
    6·2 answers
  • In 3-5 sentences, describe how you would insert a graph in your word-processing document.
    13·1 answer
  • For what kind of shot is a fisheye lens most appropriate?
    8·1 answer
  • How can you crop a photo in PowerPoint?
    15·2 answers
  • Identify the parts of it, Give at least three web browser that you usually used to visit a website.​
    10·1 answer
  • HELPPPP MEEEE!!!!! ITS LIFE OR MUERTEEE
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!