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

Define copy constructor.

1128


What is diamond problem in c++?

1010


Why do we use setw in c++?

1124


Do you know what are the new features that iso/ansi c++ has added to original c++ specifications?

1136


what Is DCS ? what i will get benefit when i did?

2371


What are exceptions c++?

1052


Is java based off c++?

992


What will happen if a pointer is deleted twice?

1199


What are the uses of c++ in the real world?

1047


How can we check whether the contents of two structure variables are same or not?

1087


Difference between overloaded functions and overridden functions

1072


Differentiate between declaration and definition.

1061


What is a dynamic binding in c++?

970


Can static member variables be private?

1191


Explain deep copy?

1069