- Pascal Tutorial
- Pascal - Home
- Pascal - Overview
- Pascal - Environment Setup
- Pascal - Program Structure
- Pascal - Basic Syntax
- Pascal - Data Types
- Pascal - Variable Types
- Pascal - Constants
- Pascal - Operators
- Pascal - Decision Making
- Pascal - Loops
- Pascal - Functions
- Pascal - Procedures
- Pascal - Variable Scope
- Pascal - Strings
- Pascal - Booleans
- Pascal - Arrays
- Pascal - Pointers
- Pascal - Records
- Pascal - Variants
- Pascal - Sets
- Pascal - File Handling
- Pascal - Memory
- Pascal - Units
- Pascal - Date & Time
- Pascal - Objects
- Pascal - Classes
- Pascal Useful Resources
- Pascal - Quick Guide
- Pascal - Useful Resources
- Pascal - Discussion
Pascal - Case Else Statement
The case-else statement uses an else term after the case labels, just like an if-then-else construct.
Syntax
The syntax for the case-else statement is −
case (expression) of L1 : S1; L2 : S2; ... ... Ln: Sn; else Sm; end;
Flow Diagram
Example
The following example illustrates the concept
program checkCase; var grade: char; begin grade := 'F'; case (grade) of 'A' : writeln('Excellent!' ); 'B', 'C': writeln('Well done' ); 'D' : writeln('You passed' ); else writeln('You really did not study right!' ); end; writeln('Your grade is ', grade ); end.
When the above code is compiled and executed, it produces the following result −
You really did not study right! Your grade is F
pascal_decision_making.htm
Advertisements
To Continue Learning Please Login
Login with Google