1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

The Use of Break in C

Discussion in 'C' started by Snader, Sep 30, 2010.

  1. Snader

    Snader New Member

    Joined:
    Sep 30, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    break;
    The break is used to (1)terminate a case in the switch statement. (2)Force an immediate termination of a loop.

    sample prog.
    Code:
    void main()
    {
        int a;
        printf("1. Happy\n");
        printf("2. Sad\n");
        printf("Enter Your Choice..");
        scanf("%d",a);
        switch(a)
        {
           case 1: {
                     printf("You are happy.");
                     break;
                   }
           case 2: {
                     printf("You are sad.");
                     break; 
                   }
           default:{
                     printf("Oops you error..");
                     break;
                   }
        }
      getch();
    }
     
  2. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    2
    Trophy Points:
    0
    So what is your question
     

Share This Page