Number Pattern 42-Pyramid pattern in C programming
Contents
hide
In this program, we will see the Pyramid pattern numbers in C programming language. Please look into the program.
1 2 4 1 3 5 2 4 6 8 1 3 5 7 9
The C program for Pyramid pattern is as follows:
#include<stdio.h> int main() { int a,b,c; for(a=1;a<=5;a++) { if(a%2==0) { c=2; } else { c=1; } for(b=1;b<=a;b++,c+=2) { printf("%d ", c); } printf("n"); } getch(); return 0; }