Switch

T

tw1s73dj0k3r

what is the use of switch in programming C?

switch() helps you make a decision based on many tests for example you
dont have to test the equality on and integer to another with a if-
else if-else structure , you may instead use a switch statement like

switch(c)
{
case 1:
//do stuff
break;
case 2:
//other stuff
break;
default:
//etc
}
so it tests the equality of integers "ONLY INTEGERS" and expressions
that can be evaluated at compile time.
cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,155
Latest member
JuliW73391
Top