C++ Programming Code Examples C++ > Pyramid Patterns Code Examples C++ program prints pattern of numbers C++ program prints pattern of numbers #include<iostream.h> #include<conio.h> void main() { clrscr(); int i, j, k, number=1, decr=8, count=0, temp; for(i=0; i<5; i++) { // this loop is to print spaces for(k=0; k<decr; k++) { cout<<" "; } // this loop is to give the required value to number for(j=0; j<i; j++) { count++; } number = count; temp = number; // this loop is to print the numbers for(j=0; j<i; j++) { cout<<number--<<" "; /* from the above statement, number is first printed, then decremented by 1 */ } cout<<"\n"; number = temp; decr=decr-2; } getch(); }