Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

Students also viewed these Databases questions

Question

Define external validation of cluster.

Answered: 1 week ago

Question

6. What questions would you suggest should be included?

Answered: 1 week ago