Nested For Loop Programming Star Shapes - Download Turbo C Language and C++ IDE and Programs Free

Latest

Perfect Collection of C Language and C++ Programs

BANNER 728X90

Sunday, December 15, 2013

Nested For Loop Programming Star Shapes

Example Program: Display the following output by nested for loop.


*
**
***
****
*****
nested for loop display star shape required

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();

}