C Language Loops :

C loops :

Sometimes we want a C program to repeat something again and again so, a loops is used to make a program do something more than one time.
Loop Types :

  • for loop
  • while loop
  • do-while loop

  • Comparison of the loop control structures :

    for loopwhile loopdo-while loop
    A for loop is used to execute and repeat a statement block depending on a condition which is evaluated at the beginning of the loop.
    Example :

    for(i=1; i<=10; i++)
    {
    s = s + i;
    p = p * i;
    }
    A while loop is used to execute and repeat a statement block depending on a condition which is evaluated at the beginning of the loop.
    Example :

    i = 1;
    while(i <= 10)
    {
    s = s + i;
    p = p * i;
    i++;
    }
    A do-while loop is used to execute and repeat a statement block depending on a condition which is evaluated at the end of the loop.
    Example :

    i = 1;
    do
    {
    s = s + i;
    p = p * i;
    i++;
    }
    while(i <= 10 )
    A variable value is initialized at the beginning of the loop and is used in the condition. A variable value is initialized at the beginning or before the loop and is used in the condition. A variable value is initialized at the before the loop or assigned inside the loop and is used in the condition.
    A statement to change the value of the condition or to increment the value of the variable is given at the beginning of the loop. A statement to change the value of the condition or to increment the value of the variable is given inside the loop. A statement to change the value of the condition or to increment the value of the variable is given inside the loop.

    Next Update

    Loading...

    Currently we improved our website User Interface and other contents. Our next update is adding video tutorials on this site so, We create a new YouTube channel, our YouTube channel name is CodeX.

    We need some time for make video tutorials (CodeX) so, stay with us and keep supporting and you know already we make a Collaboration with HackIsOn YouTube channel long time ago So, please Subscribe Our Channels