Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.
cpp prints I love Computer Science! 10 times. Copy it to your directory and add code as directed to get the while loop working.
I need help with Counting and Looping
The program in lab8.cpp prints
"I love Computer Science!!" 10 times.
1. Copy it to your directory and add code as directed to get the while loop working.
2. Once the program is compiling and running, modify it as follows:
•Instead of using constant LIMIT, ask the user how many times the message should be printed. You will need to declare a variable (e.g.int numTimes) to store the user's response and use that variable to control the loop. (Remember that all caps is used only for constants!)
•Number each line in the output, and add a message at the end of the loop that says how
many times the message was printed.
// ****************************************************************
//lab8.cpp
//
// Use a while loop to print many messages declaring your
// passion for computer science
// ****************************************************************
#include<iostream>
using namespace std;
int main{
// *** Step 2: I need to Create an int called numTimes
// *** Step 2: Get rid of this, prompt the user for numTimes instead const
int LIMIT = 10;
int count = 1;
// *** Step 2: Change this to check if count is <= numTimes
while(count <= LIMIT)
{
// *** Step 2: Change this line to output count before the phrase
cout<<I love Computer Science!!"<<endl
;
// *** Step 1: Increment count (hint: use the ++ operator)
}
// *** Step 2: Output the "Printed this message..." line
}
}
Here's an example of how the program should look when it's all finished. Bold, bracketed text stands for user input.
How many times should I print? [3]
1 I love Computer Science!!
2 I love Computer Science!!
3 I love Computer Science!!
Printed this message 3 times.