Latest Movie :
Home » , » C Program to Generate Numbers in Pyramid Pattern

C Program to Generate Numbers in Pyramid Pattern

{[['']]}


This C program generates the numbers in pyramid pattern. It takes the input from two through nine and generates the numbers in the pyramid pattern. For example if the input is 4 then the program produces the following output


   ….1
1111112 2
111113 3 3
111.4 4 4 4 & so on..
 
CODE:
#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();
}
Share this article :

Post a Comment

Feel Free to Say thanks Comment Here

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. SoftwareLibrary4u - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger