CIT-0112-PRACTICAL-2
CIT-0112-PRACTICAL-2
Here are simple and practical examples of how you can use IF statements and CASE
statements in VB.NET, based on the explanations provided.
Explanation:
Explanation:
Explanation:
Explanation:
Explanation:
This program checks the grade variable and prints a message based on the
value.
Each grade from A to D has a corresponding message.
If the grade is anything else (e.g., F or another value), the program prints "Failed."
Explanation:
The program checks the dayNumber variable, which represents the day of the
week.
Based on the number, it prints the corresponding day.
If the number is outside the range of 1 to 7, it prints "Invalid day number."
These practical examples illustrate how IF
and CASE statements work in real-world
scenarios.
IF statements are great for situations with fewer conditions or where complex
logic is required.
CASE statements are perfect for handling multiple discrete conditions with simple
outcomes.
Both control structures are key to creating dynamic and responsive programs.