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 inline functions? What is the syntax for defining an inline function?

1215


What is flag in computer?

1117


List the types of polymorphism in c++?

1152


What do you mean by a template?

1115


what is COPY CONSTRUCTOR and what is it used for?

1128


What is the extraction operator and what does it do?

1126


What are the unique features of C++.

1143


Specify some guidelines that should be followed while overloading operators?

1264


How the programmer of a class should decide whether to declare member function or a friend function?

1183


Can constructor be static in c++?

1169


Can malloc be used in c++?

1130


Can you pass an array to a function in c++?

1055


How static variables and local variablesare similar and dissimilar?

1097


Draw a flow chart and write a program for the difference between the sum of elements with odd and even numbers. Two dimensional array.

6457


What is class and structure in c++?

1255