| Forums.Sureshkumar.net : A Perfect Place to Share Knowledge Blogs Games Magazines |
|
|||||||
| 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. |
![]() |
|
|
LinkBack | Thread Tools | Rate Thread | Display Modes |
|
|
#1 (permalink) |
|
Moderator
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
|
C language - When is a switch statement better than multiple if statements?
When is a switch statement better than multiple if statements?
|
|
|
|
|
|
#3 (permalink) |
|
Senior Member
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
|
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; } |
|
|
|
|
|
#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
|
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 |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |