Posts

Showing posts with the label patterns & pyramids

* pyramid

/*  *       * * *     * * * * *    * * * * * * */ #include <stdio.h> #include <conio.h> void main() { int i, j; clrscr(); for(i = 0; i < 6; i++) { for(j = 6; j > i; j--) printf("  "); for(j = 1; j <=i; j++) printf("   *"); printf("\n"); } getch(); }

pyramid

 /* 1 2 1 3 2 1 4 3 2 1 5 4 3 2 1 */ #include <stdio.h> #include <conio.h> void main() { int i, j; clrscr(); for(i = 1; i <= 5; i++) { for(j = i; j > 0; j--) { printf("%d ", j); } printf("\n"); } getch(); }