Created
February 15, 2016 10:12
-
-
Save ashishkakkad8/9edbc783e1d490135d9e to your computer and use it in GitHub Desktop.
Pyramid in C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() { | |
int i, j, spaces = 0, sc, n = 0; | |
int k = 1; | |
printf("Enter Number of Lines = "); | |
scanf("%d",&n); | |
spaces = n - 1; | |
for (i = 1; i <= n; i++) { | |
for (sc = spaces; sc >= 1; sc--) { | |
printf(" "); | |
} | |
for (j = 1; j <= i; j++) { | |
printf("%3d", k); | |
k--; | |
} | |
k=i+j+k; | |
printf("\n"); | |
spaces--; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment