0% found this document useful (0 votes)
71 views13 pages

Welcome Printing Solutions in C

The document contains code snippets demonstrating the use of while and for loops in C programming to print repeating text or numbers. It shows examples of using while loops with conditional statements to continuously print "welcome" a set number of times or until a stopping condition is met. It also provides examples of using for loops to print multiplication tables or numbers from 1 to 10. The final example demonstrates a do-while loop that prints "welcome" 10 times before checking the loop condition.

Uploaded by

creatorvision
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views13 pages

Welcome Printing Solutions in C

The document contains code snippets demonstrating the use of while and for loops in C programming to print repeating text or numbers. It shows examples of using while loops with conditional statements to continuously print "welcome" a set number of times or until a stopping condition is met. It also provides examples of using for loops to print multiplication tables or numbers from 1 to 10. The final example demonstrates a do-while loop that prints "welcome" 10 times before checking the loop condition.

Uploaded by

creatorvision
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

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