How many Case statments can i use in Switch Statement
[B]Question asked by Visitor rasool[/b]
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++
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
Re: How many Case statments can i use in Switch Statement
I think there is no restriction on the number of Case statements.
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
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.
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
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....:cool:
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.
Re: How many Case statments can i use in Switch Statement
we can use only 257 cases including default statment
Re: How many Case statments can i use in Switch Statement
[QUOTE=nsandeep;13777]we can use only 257 cases including default statment[/QUOTE]
HI
how do u know the max limit is 257?
Yo got this information from any book or any from other source.