Monday, September 1, 2008

Print Pyramid

/* Program to print pyramid when no. of lines specified by the user*/

#include"stdio.h"
#include"conio.h"
void main()
{
clrscr();
int k,i,j,n;

printf("enter the no. of required lines");
scanf("%d",&n);
printf"(the pyramid is \n");
for(i=0;i<=n;i++)
{
for(j=n;j>=i;j--)
printf(" \t");
for(j=1;j<=i;j++)
printf("%d \t",j);
for(k=i-1;k>=1;k--)
printf("%d \t",k);
printf("\n");
}
getch();
}

0 comments: