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 adding new programming language tutorials very soon.

    We make a Collaboration with HackIsOn YouTube Channel So, Please Subscribe Their Channel and keep supporting