Sunday, February 19, 2012

C Program to print pyramid of numbers - c programs


C Program to print pyramid of numbers - c programs


//Write a c program to print pyramid of numbers
//Display pyramid of numbers in / using c language




//C Program to print pyramid of numbers

#include<STDIO.H> 
void main(){ 
int i,j; 
clrscr(); 
printf("Pyramid of numbers:\n"); 
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)

printf(" %d",i);
}
printf("\n"); 

getch(); 


Output:

Pyramid of numbers:

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5 

No comments:

Post a Comment