C
CSharp
C++
Java
Visual Basic
HTML - CSS
Android
Asp
Asp.Net
Php
Python
JavaScript
SQL
XML
Assembly
Beginners Lab Assignments
C on Unix
Code Snippets
Data Structures
Games and Graphics
Gnu-Linux
Mathematics
Sorting Searching
More...
C > Beginners Lab Assignments sample source codes
C Code > Program to construct a pyramid of any input numbers
Program to construct a pyramid of any input numbers main() { int n,row=1,col=40,i=0,j,k=0,count=1; int a[10]; clrscr(); i=n-1; printf("Pyramid of how many numbers? "); scanf("%d",&n); for (j=0;j<n;j++) { printf("Enter no.:- "); scanf("%d",&a[j]); } clrscr(); for (row=n;row>=1;row--) { k=0; k=40-(4*(row-1)); i=row-1; for (col=40;col>=k;col=(col-4)) { gotoxy(col,row); printf("%d",a[i]); --i; } } for (count=n;count>=1;count--) { k=0; k=40+(4*(count-1)); i=count-1; for (col=40;col<=k;col=(col+4)) { gotoxy(col,count); printf("%d",a[i]); --i; } } getch(); }
Privacy Policy
|
Contact
|
Advertising
|
Link to Us
|
Directory