About Me

My photo
Raipur, Chhattisgarh, India
Hi , I am Amit Thakur. I have worked as a QA Engineer for two years and as a Java Developer for one year in NIHILENT TECHNOLOGIES PVT. LTD., Pune.Currently I am working as DEAN (Research & Development) in Bhilai Institute of Technology, Raipur.

Saturday, December 10, 2011

Pattern Printing 1


#include
#include

void main()
{
int row, c, n, temp;

printf("Enter the number of rows in pyramid of stars you wish to see ");
scanf("%d",&n);

temp = n;

for ( row = 1 ; row <= n ; row++ )
{
for ( c = 1 ; c < temp ; c++ )
{
printf(" ");
}

temp--;

for ( c = 1 ; c <= 2*row - 1 ; c++ )
{
printf("*");
}
printf("\n");
}

getch();
}
-------------

Output:-

Enter the number of rows in pyramid of stars you wish to see 6
     *
    ***
   *****
  *******
 *********
***********

No comments: