Monday, December 10, 2007

How to use CASE switch

How to use CASE switch

To use CASE switch

#include

main( )

{ int car_type, tyle_class;

cout<<" Please Choose A Car ------->> 1 for mercedes and 2 for BMW";

cout<<" \n Please Choose A Car Tyle class ";

cout<<" \n ----- MERCEDES ------";

cout<<"\n 1 for Rally Class 2 for Racer Class & 3 for Normal Class";

cout<<"\n\n ------ BMW ------";

cout <<"\n 1 for Home Class 2 for Country site Class & 3 for Normal Class";

cout<<"\n\n Please selct a car : ";

cin >>car_type;

switch (car_type)

{

case 1 : cout<<"\n Mercedes";

cout<<"\n Select tyle class ";

cin>>tyle_class;

switch (tyle_class)

{ case 1 : cout<<"\n Rally class";

break;

case 2 : cout<<"\n Racer class";

break;

default : cout<<"\n Normal class";

}

break;

case 2 : cout<<"\n BMW ";

cout<<"\n Select tyle ";

cin>>tyle_class;

switch (tyle_class)

{ case 1 : cout<<"\n Home use class";

break;

case 2 : cout<<"\n Country site class";

break;

default : cout<<"\n Normal class";

}

break;

default : cout<<"\n No Such A Car Exist";

}

return 0;

}

Result :

No comments: