Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Given the following seqment of code containing a group of
nested if instructions: y = 9; if ((x==3) || (x == 5)) y++;
else if (x == 2) y *= 2; else if (x == 4 ) y-= 7; else y =
8; Enter a segment of code (without any IF statements) that
does exectly the same thing using the switch structure.

Answer Posted / isha

y=9;
switch(x)
{
case 2:y*=2;
break;
case 3:
case 5: y++;
break;
case 4:y-=7;
break;
default:y=8;
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the rules for naming an identifier?

1057


What are c++ templates used for?

1129


What's the order in which the local objects are destructed?

1254


What is malloc in c++?

1004


How do you find out if a linked-list has an end? (I.e. The list is not a cycle)

1149


what are the characteristics of Class Members in C++?

1028


What is istream and ostream in c++?

1114


What does the ios::ate argument do?

1166


What is flush c++?

991


What is the benefit of encapsulation?

1065


What are the advantages of using const reference arguments in a function?

1060


Should I learn c or c++ first?

1109


What is static function? Explain with an example

1051


What is the best c++ compiler?

1134


What is vector processing?

1135