In this exercise you will create a program that displays the
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 Cpp8\\Chap08 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.)
Solution
#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;
}
