Use while loop to build menus. - C Statement

C examples for Statement:while

Description

Use while loop to build menus.

Demo Code

#include <stdio.h> 
int main()//from w  w w  .j a v  a 2 s .  c o  m
{ 
   int iSelection = 0; 
   while ( iSelection != 4 ) { 
      printf("1\tDeposit\n"); 
      printf("2\tWithdraw\n"); 
      printf("3\tPrint\n"); 
      printf("4\tQuit\n"); 
      printf("Enter your selection (1-4): "); 
      scanf("%d", &iSelection); 
  }  
  printf("\nThank you\n"); 
}

Result


Related Tutorials