Guest

Most Urgent C++ Problems -- Give definitions of the following : - a)simple if b)if..else c)if..else..if d)switch Please give only and only definitions.No examples nothing else.



Most Urgent C++ Problems --


Give definitions of the following : -


a)simple if


b)if..else


c)if..else..if


d)switch


Please give only and only definitions.No examples nothing else.



Grade:11

2 Answers

SAGAR SINGH - IIT DELHI
878 Points
13 years ago

Dear nitin,

  if ( TRUE ) Execute the next statement


if ( TRUE ) {
  // Execute these statements if TRUE
}
else {
  // Execute these statements if FALSE
}


if ( <condition> ) {
  // Execute these statements if <condition> is TRUE
}
else if ( <another condition> ) {
  // Execute these statements if <another condition> is TRUE and
  // <condition> is FALSE
}
The switch statement provides a convenient alternative to the if when dealing with a multi-way branch. Suppose we have some integer value called test and want to do different operations depending on whether it has the value 1, 5 or any other value, then the switch statement could be employed:-
switch ( test ) {

  case 1 : 
    // Process for test = 1
    ...
    break;

  case 5 : 
    // Process for test = 5
    ...
    break;

  default : 
    // Process for all other cases.
    ...

}
Please feel free to ask your queries here. We are all IITians and here to help you in your IIT JEE preparation. All the best. Win exciting gifts by answering the questions on Discussion Forum. So help discuss any query on askiitians forum and become an Elite Expert Leagueaskiitian. Now you score 5+15 POINTS by uploading your Pic and Downloading the Askiitians Toolbar  respectively : Click here to download the toolbar.. Askiitians Expert Sagar Singh B.Tech, IIT Delhi 



Nitin Gupta
16 Points
13 years ago

I got the definition of switch statement from your answer.But what can I write in the definition of simple if,if-else,if-else-if?There is no need to give examples.I know these things but just don't know the definition.

Thanks for you replies in this and other questions

Think You Can Provide A Better Answer ?

ASK QUESTION

Get your questions answered by the expert for free