Tuesday, December 6, 2011

Write a C Program to Create number pyramid II

#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,j,x=40,y=10;
clrscr();
printf("Enter n (between 2 & 9)\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
gotoxy(x,y); /* To take the cursor to the co-ordinates x & y */
for(j=1;j<=i;j++)
{
 printf("%d ",i);
}
x=x-1;
y++;
}
getch();
}

No comments:

Post a Comment