Back To C++ Loops Index
program to print pattern
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
//program to input a number n and print pattern of numbers from 1 to n (example of nested loop) #include
#include
void main() { int n; int i,j; clrscr(); printf("\nenter a value for n "); scanf("%d",&n); for(i=1;i<=n;i++) { for(j=1;j<=i;j++) { printf("%d\t",j); } printf("\n"); } getch(); }