Thread: The Switch Statement

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    24

    The Switch Statement

    I am writing the following Switch Statement


    switch( Choice )
    {
    case 1;
    Num=Rational();
    printf("%f",Num);
    break;
    case 2;
    cp=String();
    puts(cp);
    break;
    case 3;
    break;


    can anyonet ell me why Im getting the following compilation error:
    "Missing ';' before ';'

    Thanks

  2. #2
    Im a Capricorn vsriharsha's Avatar
    Join Date
    Feb 2002
    Posts
    192

    Thumbs up

    You Are using Semi Colon ( for case... It should be a ":"

    So, ur code should be...

    switch( Choice )
    {
    case 1:
    Num=Rational();
    printf("%f",Num);
    break;
    case 2:
    cp=String();
    puts(cp);
    break;
    case 3:
    break;
    - - -
    }

    Regards,
    Sriharsha
    Help everyone you can

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    24

    The Siwtch Statement

    Thanks!!!!!!
    And if you get no joy from music hall
    Remember there is always alcohol
    And If you get no joy from Gin
    Here is the abyss jump in

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mutli Switch statement help
    By elwad in forum C Programming
    Replies: 9
    Last Post: 05-09-2009, 03:19 AM
  2. Switch statement / default:
    By kcpilot in forum C Programming
    Replies: 4
    Last Post: 12-02-2008, 03:14 PM
  3. switch statement
    By guillermoh in forum C Programming
    Replies: 5
    Last Post: 03-10-2008, 02:17 PM
  4. char switch statement
    By jmarsh56 in forum C++ Programming
    Replies: 7
    Last Post: 05-03-2006, 05:04 PM
  5. Efficiency with the switch() statement...
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 10-14-2001, 02:47 PM