Thursday, July 9, 2009

Could anybody please tell me the syntax for switch statement in Turbo C?

And could anyone please give me a link where to find more information? Highly appreciated... thanks

Could anybody please tell me the syntax for switch statement in Turbo C?
try this:





switch (j)


{


case 1: p("\n\n\n\n\tEnter the temperature in Celsius : ");


s("%d",%26amp;x);


p("\n\t%d Celsius is equal to %.2f fahrenheit", x, celtofah(x));


break;





case 2: p("\n\n\n\n\tEnter the temperature in Fahrenheit: ");


s("%d",%26amp;x);


p("\n\t%d Fahrenheit is equal to %.2f Celsius", x, fahtocel(x));


break;





default: p("Invalid Selection");


break;


}





this is an example of a switch coding:





switch()


{


case :


break;





...


...


...





default :


break
Reply:Turbo C implements standard C language. In C language,


the switch statement syntax is:





switch(...)


{


case ... : command;


command;


break;





case ... : command;


break;





default :


command;


}
Reply:switch ( variable )


{


case : 1


break;





case : 2


break ;





Default


}


No comments:

Post a Comment