Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

How many Case statments can i use in Switch Statement

This is a discussion on How many Case statments can i use in Switch Statement within the C and C++ forums, part of the Software Development category; 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; ...

Go Back   Geeks Talk > Software Development > C and C++
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 04-09-2007
Expert Member
 
Join Date: Feb 2007
Posts: 1,279
Thanks: 0
Thanked 192 Times in 154 Posts
Geek_Guest has a spectacular aura aboutGeek_Guest has a spectacular aura aboutGeek_Guest has a spectacular aura about
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++
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-17-2007
Junior Member
 
Join Date: Apr 2007
Location: india
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
julus_143 is on a distinguished road
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
Reply With Quote
  #3 (permalink)  
Old 04-18-2007
Expert Member
 
Join Date: Nov 2006
Location: Hyd-IND
Posts: 528
Thanks: 1
Thanked 63 Times in 50 Posts
sutnarcha is on a distinguished road
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-
Reply With Quote
  #4 (permalink)  
Old 04-19-2007
Junior Member
 
Join Date: Mar 2007
Location: chennai
Posts: 18
Thanks: 15
Thanked 0 Times in 0 Posts
dhanasweet is on a distinguished road
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
Reply With Quote
  #5 (permalink)  
Old 04-19-2007
Junior Member
 
Join Date: Mar 2007
Location: tamilnadu
Posts: 10
Thanks: 0
Thanked 3 Times in 2 Posts
saranyamahendran is on a distinguished road
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.
Reply With Quote
  #6 (permalink)  
Old 04-19-2007
Junior Member
 
Join Date: Apr 2007
Location: india
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
julus_143 is on a distinguished road
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
Reply With Quote
  #7 (permalink)  
Old 05-02-2007
Junior Member
 
Join Date: Oct 2006
Location: Kolkata
Posts: 5
Thanks: 0
Thanked 2 Times in 1 Post
sat_yucky is on a distinguished road
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....
Reply With Quote
  #8 (permalink)  
Old 06-04-2007
Junior Member
 
Join Date: Feb 2006
Posts: 8
Thanks: 0
Thanked 3 Times in 2 Posts
mef526 is on a distinguished road
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.
Reply With Quote
  #9 (permalink)  
Old 06-24-2007
Junior Member
 
Join Date: Jun 2007
Location: SRIKAKULAM
Posts: 4
Thanks: 2
Thanked 0 Times in 0 Posts
nsandeep is on a distinguished road
Re: How many Case statments can i use in Switch Statement

we can use only 257 cases including default statment
Reply With Quote
  #10 (permalink)  
Old 07-03-2007
Junior Member
 
Join Date: Feb 2007
Posts: 15
Thanks: 2
Thanked 1 Time in 1 Post
rpgubba is on a distinguished road
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.
Reply With Quote
Reply

  Geeks Talk > Software Development > C and C++

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Use case statement and Test Case JobHelper Testing Issues 4 01-16-2009 03:48 AM
Is this a correct statement anoop4real C and C++ 13 05-22-2008 07:22 AM
C/C++ Programming : Limitations of switch statement Lokesh M C and C++ 1 07-17-2007 03:38 AM
find the correct switch..... psuresh1982 Brainteasers 7 02-08-2007 04:57 AM
Vlan on layer 3 switch nikhil_rattan Networking 2 01-18-2007 02:33 AM


All times are GMT -4. The time now is 03:54 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved