Results 1 to 10 of 10

Thread: How many Case statments can i use in Switch Statement

  1. #1
    Geek_Guest
    Guest

    How many Case statments can i use in Switch Statement

    Question asked by Visitor rasool

    If i use "switch" statement how many "case" statments can i use
    ex :-
    int n;
    cout<<"enter the choice";
    cin>>n;
    switch (n)
    case 1:cout<<"one";
    break;
    case 2:cout<<"two";
    break;
    -----
    -----
    -----
    like this how many case statement I can use in C & C++


  2. #2
    Junior Member
    Join Date
    Apr 2007
    Answers
    2

    Thumbs up Re: How many Case statments can i use in Switch Statement

    u can use any no of case staments ,if u want millian no of case statements then i can't say whether it will work or not


  3. #3
    Expert Member
    Join Date
    Nov 2006
    Answers
    518

    Re: How many Case statments can i use in Switch Statement

    I think there is no restriction on the number of Case statements.

    Lack of WILL POWER has caused more failure than
    lack of INTELLIGENCE or ABILITY.

    -sutnarcha-

  4. #4
    Junior Member
    Join Date
    Mar 2007
    Answers
    3

    Re: How many Case statments can i use in Switch Statement

    in ur program n is an integer,so u can use this within the limit
    of int


  5. #5

    Re: How many Case statments can i use in Switch Statement

    hai..
    there is no limit in the cases in the switch.
    the only limitation is that they should not have same cases twices.


  6. #6
    Junior Member
    Join Date
    Apr 2007
    Answers
    2

    Re: How many Case statments can i use in Switch Statement

    thanks for reply
    and my another question is
    How cand i create dyanamic arrays in c or c++ or java


  7. #7
    Junior Member
    Join Date
    Oct 2006
    Answers
    5

    Re: How many Case statments can i use in Switch Statement

    As such no restrictions are laid by C compiler..... As long as your memory size permits, you can use Switch cases....


  8. #8
    Junior Member
    Join Date
    Feb 2006
    Answers
    8

    Re: How many Case statments can i use in Switch Statement

    No limit is defined in the standard, however, it depends on the size of the int. If int is 32 bits then the limit is 2^32-1. But that is not practical given system resources.


  9. #9
    Junior Member
    Join Date
    Jun 2007
    Answers
    2

    Re: How many Case statments can i use in Switch Statement

    we can use only 257 cases including default statment


  10. #10
    Junior Member
    Join Date
    Feb 2007
    Answers
    13

    Re: How many Case statments can i use in Switch Statement

    Quote Originally Posted by nsandeep View Post
    we can use only 257 cases including default statment
    HI
    how do u know the max limit is 257?
    Yo got this information from any book or any from other source.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact