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 pointers?

1058


What is the difference between a pointer and a link in c ++?

1057


What programming language should I learn first?

1103


Can the operator == be overloaded for comparing two arrays consisting of characters by using string comparison?

1083


Explain queue. How it can be implemented?

1161


On throwing an exception by the animal constructor in p = new animalq, can memory leak occur?

1136


What is difference between rand () and srand ()?

1090


What is virtual methods?

1129


What is nested class in c++?

965


What is Destructor in C++?

1197


What is meant by iomanip in c++?

1220


What is a responder chain?

1054


What is pure virtual function? Or what is abstract class?

1063


Why do we need constructors in c++?

1113


Which coding certification is best?

1033