In this exercise, you will create a program that displays the pattern of asteris
ID: 3924588 • Letter: I
Question
In this exercise, you will create a program that displays the pattern of asterisks shown in Figure 8-26. Use the whi1e statement for the outer loop. Use the do whi1e statement for the nested loop. If necessary, create a new project named TryThis10 Project, and save it in the Cpp8Chap08 folder. Enter the C++ instructions into a source file named TryThis10.cpp. Also enter appropriate comments and any additional instructions required by the compiler. Save and then run the program. (The answers to TRY THIS Exercises are located at the end of the chapter.)Explanation / Answer
#include <iostream>
using namespace std;
int main()
{
int row=5,col=1;
while(row>0)
{
col=1;
do{
cout<<'*';
col+=1;
}while(col<=row);
cout<<endl;
row-=1;
}
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.