Monday, 8 December 2014

C Program to print pyramid pattern

Program to print pattern
#include<stdio.h>
main()
{
int i,j,k,n;
printf("enter value for n\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<=2*n-i;j++)
printf(" ");
for(j=0;j<=2*i;j++)
printf("*");
printf("\n");
}
}
OutPut:
madan@madan-Lenovo-G570:~/madan$ cc pyramid4.c
madan@madan-Lenovo-G570:~/madan$ ./a.out
enter value for n
5
           *
          ***
         *****
        *******
       *********