Thread: hii..switch and case

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    36

    hii..switch and case

    Hi..everyone..i got 1 question..Insted of using switch and case to do our control, do we have any choice to do it..yea..i know we can use while loop..can gave some tips or advice for using while loops to replace switch case..Thanks

  2. #2
    Registered User
    Join Date
    Jun 2004
    Posts
    722
    while?? no
    lots of ifs, and else yes
    Code:
    switch(some_var){
    case 1: ...; break;
    case 2: ...; break;
    case 3: ...; break;
    case 4: ...; break;
    case 5: ...; break;
    default: break;
    }
    
    //OR
    if(some_var == 1){
    }else if(some_var == 2){
    }else if(some_var == 3){
    }else if(some_var == 4){
    }else if(some_var == 5){
    }else{ //default
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How can I make this code more elegant?
    By ejohns85 in forum C++ Programming
    Replies: 3
    Last Post: 04-02-2009, 08:55 AM
  2. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 05:42 PM
  3. ascii rpg help
    By aaron11193 in forum C Programming
    Replies: 18
    Last Post: 10-29-2006, 01:45 AM
  4. Xmas competitions
    By Salem in forum Contests Board
    Replies: 88
    Last Post: 01-03-2004, 02:08 PM
  5. opengl program as win API menu item
    By SAMSAM in forum Game Programming
    Replies: 1
    Last Post: 03-03-2003, 07:48 PM