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...

    We have a YouTube channel for live game streaming purposes, the channel name is "NightHawk". You can visit our gaming channel and support us, Thank you