9 Mar 2013

Pattern_nested LOOP

/*

program to generate following pattern......


    *
   ***
  *****
 *******
*********



 */




#include<iostream.h>
#include<conio.h>
 

void main()
{
clrscr();
 

int i,j,r,a=1;
 

for(i=1;i<=5;i++)
 {
  for(j=5;j>i;j--)
   {
    cout<<" ";
   }
  for(r=1;r<=a;r++)
   {
    cout<<"*";
   }
  cout<<'\n';
  a+=2;
 }
 

getch();
}

Categories: ,

0 comments:

Post a Comment

Copyright © UPgradeCODING | Powered by Blogger