Flag Mechanics> C++...
question mark

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.

Nitin Gupta , 15 Years ago
Grade 11
anser 2 Answers
SAGAR SINGH - IIT DELHI

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 



ApprovedApproved
Last Activity: 15 Years ago
Nitin Gupta

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

Last Activity: 15 Years ago
star
LIVE ONLINE CLASSES

Prepraring for the competition made easy just by live online class.

tv

Full Live Access

material

Study Material

removal

Live Doubts Solving

assignment

Daily Class Assignments