Question: Exercise 1: conditional executions Complete the following program by writing C++ statements that correspond to the description in each comment in the code. Make sure

Exercise 1: conditional executions

Complete the following program by writing C++ statements that correspond to the description in each comment in the code. Make sure all output to the screen has newlines after it.

#include

#include

using namespace std;

int main()

{

// declare a variable to hold a character and initialize it

// to the letter H

// print "The value of the variable is "

// prompt the user to enter a value

// store whatever character the user types in your variable

// if the user typed W print "Excellent. "

// otherwise print, "No, you fool! "

return 0;

}

Exercise 2: conditional loops

1. How many times does the following loop execute? What is the value of the variable i after the loop is done?

int i = 1;

while( i < 10 )

{

i = i + 2;

}

2. What is the output of the following C++ code?

int count = 1;

int y = 100;

while ( count < 100 )

{

y = y - 1;

count++;

}

cout << "y = " << y << " and count = " << count << endl;

3. Given a double variable n, write C++ statements to ask the user to enter a real number repeatedly until the user enters a number that is greater than n. Store the user number in a double variable number.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!