Forums.Sureshkumar.net : A Perfect Place to Share Knowledge         Blogs     Games    Magazines    

"Sharing knowledge does not lessen your store, often it gets you more. Sharing plays a key role in relationships and bonding, happens in small steps and is assisted through community membership."

Go Back   SURESHKUMAR.NET FORUMS > TECHNICAL DISCUSSIONS > DATA STRUCTURES, C, C++, VC ++ > ds. c , c++ Interview / Technical Questions
Register FAQ Members List Calendar Games Blogs Search Today's Posts Mark Forums Read

ds. c , c++ Interview / Technical Questions Kindly solve an many as questions you can. It will sharpen your skills and those solutions will help others too.

   

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
Old 23-01-07, 01:44 PM   #1 (permalink)
Moderator
 
GEEK's Avatar
 
Join Date: Nov 2006
Age: 25
Posts: 227
Thanks: 1
Thanked 12 Times in 9 Posts
Thanks: 1
Thanked 12 Times in 9 Posts
Rep Power: 6 GEEK is on a distinguished road GEEK is on a distinguished road
C language - When is a switch statement better than multiple if statements?

When is a switch statement better than multiple if statements?
GEEK is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-10-07, 09:41 PM   #2 (permalink)
Junior Member
 
Join Date: Oct 2007
Age: 21
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 2 phaneendra_vemuri is on a distinguished road
Re: C language - When is a switch statement better than multiple if statements?

when we chose a selection option in the program
phaneendra_vemuri is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-10-07, 12:45 AM   #3 (permalink)
TAM
Senior Member
 
TAM's Avatar
 
Join Date: Oct 2006
Location: Mayiladurai (TN)
Posts: 233
Thanks: 8
Thanked 7 Times in 5 Posts
Thanks: 8
Thanked 7 Times in 5 Posts
Rep Power: 5 TAM is on a distinguished road
Re: C language - When is a switch statement better than multiple if statements?

Switch is better than multiple if for the following case

-> When we have to compare a number or variable with other elements for equality

i.e int c;
scanf("%d",&c)
switch (c)
{
case 1:
printf("One");
break;

case 2:
printf("Two");
break;

case 3:
printf("Three");
break;
}
TAM is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-02-08, 03:48 PM   #4 (permalink)
Junior Member
 
Join Date: Feb 2008
Posts: 25
Thanks: 3
Thanked 2 Times in 2 Posts
Thanks: 3
Thanked 2 Times in 2 Posts
Rep Power: 1 bharathi chowdary will become famous soon enough
Re: C language - When is a switch statement better than multiple if statements?

1.When we want to save the time instead of writing multiple if statements and
2.to write the code in a clear understandable manner
bharathi chowdary is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 On

Similar Threads
Thread Thread Starter Forum Replies Last Post
C language - What does it mean when a pointer is used in an if statement GEEK ds. c , c++ Interview / Technical Questions 0 23-01-07 01:41 PM
C language -When is a switch statement better than multiple if statements? GEEK ds. c , c++ Interview / Technical Questions 0 23-01-07 01:18 PM
C language -Can we use string in switch statement? GEEK ds. c , c++ Interview / Technical Questions 0 23-01-07 01:10 PM
java JSP naga JAVA Technologies 4 21-08-06 05:03 PM
regarding oracle versions Madhuri ORACLE , SQL SERVER , SYBASE & Others 7 07-07-06 07:06 PM


All times are GMT +6.5. The time now is 01:24 PM.





Search Engine Optimization by vBSEO 3.1.0