-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwitchOperatorDEMO1.cpp
More file actions
57 lines (48 loc) · 1.28 KB
/
Copy pathSwitchOperatorDEMO1.cpp
File metadata and controls
57 lines (48 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//************************************************************************
// Author: Rolando Carreon
// Date: feb 13 2025
// Language: C++
// Assignment: SwitchOperatorDEMO
// Description: demonstarte switch strcutures
//************************************************************************
#include<iostream>
using namespace std;
int main()
{
// declare local variables //
int day;
// get the day number from the user //
cout << "Enter a day number (1-7): ";
cin >> day;
// switch on the day number and display the day //
// you may not always want to add a break if the switch counts as 2 categories
// switch only uses int, char, and enum variables
switch(day)
{
case 1:
cout << "Monday\n";
break;
case 2:
cout << "Tuesday\n";
break;
case 3:
cout << "Wednesday\n";
break;
case 4:
cout << "Thursday\n";
break;
case 5:
cout << "Friday\n";
break;
case 6:
cout << "Saturday\n";
break;
case 7:
cout << "Sunday\n";
break;
default:
cout << "Invalid day number\n";
break;
}
return 0;
}