Break keyword is used with the if command to exit the loop when you press the ~ (tilde) key: - C Data Type

C examples for Data Type:char

Description

Break keyword is used with the if command to exit the loop when you press the ~ (tilde) key:

Demo Code

#include <stdio.h>
int main()// ww  w  . j  av  a  2  s .  c o m
{
   char ch;
   puts("Start typing");
   puts("Press ~ then Enter to stop");
   for(;;)
   {
      ch=getchar();
      if(ch=='~')
      {
         break;
      }
   }
   printf("Thanks!\n");
   return(0);
}

Result


Related Tutorials