Example Program: Display the following output by nested for loop.
*
**
***
****
*****
![nested for loop display star shape required](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhicH4jX9b9Sd8UOD_6E77B768q203q5n5a7mskel_jyb8hSSimUiBytxVcDvxIxVQvSMQgCQpOMEe6Vwqkor8rpahmjdCbDj_vk7e2kR40Rt6myyDhvDoC7rOyN9GU0zrXtzrkQ6uuttzq/s1600/nested-for-loop-star-shape-display.gif)
Solution:
/*
Write a C++ Program to display the following
output by nested for loop.
For Free C++ Programming Techniques (Example Programs), visit
Www.EasyCppProgramming.Blogspot.Com
and For Good Notes
Visit Www.ForFreeEducation.Blogspot.Com
*/
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int counter1, counter2;
cout<<"\n\n ----------- Results ------------\n";
for ( counter1 =1; counter1<=5; counter1++)
{
for(counter2=1; counter2<=counter1; counter2++)
cout<<"*";
cout<<endl;
}
getch();
}
0 comments:
Post a Comment
We Love To Hear From You!