0% found this document useful (0 votes)
18 views9 pages

PPS Lab PPT

Uploaded by

Hara Prasad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views9 pages

PPS Lab PPT

Uploaded by

Hara Prasad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

ALabPPTreport on

SwitchCaseStatement
Bachelor of Technologyincomputer science&Engineering
(Data Science)

Submittedby
D. Adhinadh-247R1A6716
Under theguidanceof

Shankar sir

Department of Humanities & Sciences


(UGC Autonomous)
Session:2024-2025
PPS LAB PPT
SWITCH CASE STATEMENT
Introduction to Switch Case

 Content =

 The switch statement is used to simplify


complex if-else ladders
 Works with int, char, and enum data types.
Syntax:
 switch(expression) {
 case constant1:
 // code block//
 break;
 case constant2:
 // code block//
 break;
 default:
 // default code block//
 }
Flowchart
 Title : Flow of Execution in Switch Case
 Include a simple flowchart :
 ->Start
 -> Evaluate Expression
 -> Match Case
 -> Execute Block
 -> Check for break
 -> Move to Default (if no match)
 -> End
Working Process

 Steps :
 Evaluate the (switch) expression.
 Compare it with each (case) label.
 Execute the matching (case) block.
 Exit the switch using (Break).
 If no match, execute the (default) block.
 Emphasize importance of (Break) to avoid fall-
through
Example Program
 #include <stdio.h>
 int main() {
 int choice;
 printf("Enter a number (1-3): ");
 scanf("%d", &choice);
 switch(choice) {
 case 1:
 printf("You chose One.\n");
 break;
 case 2:
 printf("You chose Two.\n");
 break;
 case 3:
 printf("You chose Three.\n");
 break;
 default:
 printf("Invalid choice.\n");
 }
 return 0;
 }
 Output :
 Input =2
Key Points
 Key Points & Summary
 Simplifies multi-branch decision-making.
 Efficient for scenarios with known values.
 Ensure to use break to prevent unintended fall-
through.

You might also like