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

How do we implement inheritance in c++?

1068


What are multiple inheritances (virtual inheritance)?

1020


What does it mean to declare a destructor as static?

1016


Does c++ support multilevel and multiple inheritances?

948


What is a tree in c++?

915


What is ctime c++?

1058


Can I create my own functions in c++?

1037


What does obj stand for?

1086


What is the difference between mutex and binary semaphore?

1113


Discuss the effects occur, after an exception thrown by a member function is unspecified by an exception specification?

1014


Explain rethrowing exceptions with an example?

978


why is iostream::eof inside a loop condition considered wrong?

1007


what is upcasting in C++?

1116


How do I get good at c++ programming?

1083


How the delete operator differs from the delete[]operator?

1048