C++ Online Compiler
Example: C++ program of decision making by using the switch case statement
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// C++ program of decision making by using the switch case statement #include <iostream> using namespace std; int main() { int w; cout << "Enter the week number among 1 to 7\n"; cin >> w; if (w) { switch (w) { case 1: cout << "Hi\nIt's sunday on today, It's the week-off day.\n"; break; case 2: cout << "Hi\nIt's monday on today, It's the working day.\n"; break; case 3: cout << "Hi\nIt's tuesday on today, It's the working day.\n"; break; case 4: cout << "Hi\nIt's wednesday on today, It's the working day.\n"; break; case 5: cout << "Hi\nIt's thursday on today, It's the working day.\n"; break; case 6: cout << "Hi\nIt's friday on today, It's the working day.\n"; break; case 7: cout << "Hi\nIt's saturday on today, It's the week-off day.\n"; break; // w parameter doesn't match any case constant then It navigates to default: default: cout << "Sorry, You entered the wrong week number, Kindly try again\n"; } } else { cout << "Sorry didn't entered any week number!\n"; } return 0; }
7
Output
Clear
ADVERTISEMENTS