Skip to content

Instantly share code, notes, and snippets.

@ashishkakkad8
Created February 15, 2016 10:12
Show Gist options
  • Save ashishkakkad8/9edbc783e1d490135d9e to your computer and use it in GitHub Desktop.
Save ashishkakkad8/9edbc783e1d490135d9e to your computer and use it in GitHub Desktop.
Pyramid in C
#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