This C++ program takes an input of a day's number and uses a switch statement to check whether the entered day is a weekend day or not. Here's how the program works:
Overall, this program is a good example of how to use a switch statement in C++ to handle multiple cases. However, it could be improved by adding input validation to check that the entered day number is within the correct range of 1 to 7. Additionally, it could be modified to output the day's name instead of a statement about the weekend.
#include<iostream> using namespace std; int main() { int day; cout<<"\nEnter the Day's number :"; cin>>day; switch(day) { case 6: cout<<"\nToday is Saturday"; break; case 7: cout<<"\nToday is Sunday"; break; default: cout<<"\nLooking forward to the Weekend"; } return 0; }To download raw file Click Here
Enter the Day's number :5 Looking forward to the Weekend
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions