C Looping Make computer repeat task for you

Likewise in real world , we must repeat task in order to meet certain requirement .There are three loops in C programming:

  1. while loop
  2. do...while loop
  3. for loop

WHILE LOOP

You’ll find that while statements are just as easy to use as if statements. For

This causes the two lines within the braces to be executed repeatedly until a is greater than or equal to b. The while statement in general works as illustrated to the right.

TASKS


  1. Generate following output.
0
1
2
3
4
5
1
2
3
4
5
6
  1. Print your name 10 times , using only one variables

do-while loop

C also provides a do-while structure:

TASKS


  1. Print your name 10 times , using only one variables
(adsbygoogle = window.adsbygoogle || []).push({});

for loop

The for loop in C is simply a shorthand way of expressing a while statement. For example, suppose you have the following code in C:

x = 1;
while ( x < 10)
{
blah blah blah
x ++; / ∗ x++ is the same as saying x = x+1/
}
1
2
3
4
5
6

You can convert this into a for loop as follows:

for ( x = 1 ; x < 10 ; x ++)
{
blah blah blah
}
1
2
3
4

Note that the while loop contains an initialization step (x=1), a test step (x<10), and an increment step (x++). The for loop lets you put all three parts onto one line

TASKS


  1. Print your name 10 times , using only one variables

Conclusion

In order to repeat statement , we must follow three step :

  1. Initialization
  2. Test Condition
  3. Update(Increment or Decrement)
var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date(); (function(){ var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0]; s1.async=true; s1.src='https://embed.tawk.to/5bd7b562476c2f239ff683f0/default'; s1.charset='UTF-8'; s1.setAttribute('crossorigin','*'); s0.parentNode.insertBefore(s1,s0); })();
(adsbygoogle = window.adsbygoogle || []).push({});