Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 13

Scenario To print : welcome welcome welcome welcome welcome Solution: Printf(welcome welcome welcome welcome welcome);

Main() { int i=1; While(i<10) { Printf(welcome); i++; } }

Main() { int i=10; While(i>=1) { Printf(welcome %d,i); i--; } }

Main() { int i=1; While(i<10) { Printf(%d, i); i++; } }

Main() { int i=1; While(i<10) { Printf(%d X 5=, i); i++; } }

Main() { int i=1,n; printf(enter the table value:); scanf(%d,&n); While(i<10) { Printf(%d X %d = %d, i,n, i*n); i++; } }

Main() { While(1) { Printf(welcome); } }

To stop while loop. printf("enter 0 to quit"); scanf("%d", &response); while (response!=0) { printf("Try again!!!!!!!"); scanf("%d", &response); } Printf(u have successfully quit the program);

The for Loop Main() { int i; for(i=1; i<10; i++) { Printf(welcome); } }

To print: 1X1=1 2X2=4 3X3=9 . . .

Main() { int i; for(i=1,j=1; i<10; i++, j=j+2) { Printf(%dX%d=%d,i,j,i*j); } }

Main() { int i=10; do { Printf(welcome); I--; } while(i>1);

You might also like