indefinite loop: empty for : For statement « Statement « C Tutorial






#include <stdio.h>
#include <ctype.h>           /* For tolower() function */

int main(void)
{
  char answer = 'N';

  printf("\nThis program calculates the average of any number of values.");

  for( ;; )                           /* Indefinite loop */
  {
    printf("Do you want to enter another value? (Y or N): ");
    scanf(" %c", &answer );

    if( tolower(answer) == 'n' ){
      break;
    }
  }

  return 0;
}
This program calculates the average of any number of values.Do you want to enter another value? (Y o
     r N): N








6.6.For statement
6.6.1.for LOOP
6.6.2.Omit all three parts in for loop
6.6.3.The for loop with a comma operator
6.6.4.Initialize loop control variable outside the for statement
6.6.5.Use for loop to print a rectangle
6.6.6.Sum integers in for statement
6.6.7.for loop backward
6.6.8.indefinite loop: empty for
6.6.9.Nest if statement in for loop
6.6.10.Nest for loop: two different control variables
6.6.11.Use char variable to control for loop
6.6.12.Continue a for loop