Why the Switch statement is used?

Asked By 0 points N/A Posted on -
qa-featured

I have a question on Switch statement in C program. Why the Switch statement is used? Could you explain with an example so that I can prepare well for my exams?

SHARE
Best Answer by Sharath Reddy
Answered By 5 points N/A #329668

Why the Switch statement is used?

qa-featured

Switch statement is a multi way decision making system in C programming language.

General syntax of the switch statement is as follows

 

Switch (expression)

{

Case 1:

Statement 1;

break;

 

Case 2:

Statement 2;

break;

.

.

.

Default:

statement;

break;

 

}

 

  • It checks the value of the given expression against the list of case values provided. If the condition is satisfied, then the block of statements inside the case value will be executed.

The break statement at the end of each case block shows the end of that case and exit from the switch statement.

Login/Register to Answer

Related Questions