File tree Expand file tree Collapse file tree 1 file changed +27
-32
lines changed
Expand file tree Collapse file tree 1 file changed +27
-32
lines changed Original file line number Diff line number Diff line change @@ -10,38 +10,33 @@ int main()
1010 /* Input week number from user */
1111 cout << " Enter week number(1-7): " << endl;
1212 cin >> week;
13-
14- if (week == 1 )
15- {
16- cout << " Monday" << endl;
17- }
18- else if (week == 2 )
19- {
20- cout << " Tuesday" << endl;
21- }
22- else if (week == 3 )
23- {
24- cout << " Wednesday" << endl;
25- }
26- else if (week == 4 )
27- {
28- cout << " Thursday" << endl;
29- }
30- else if (week == 5 )
31- {
32- cout << " Friday" << endl;
33- }
34- else if (week == 6 )
35- {
36- cout << " Saturday" << endl;
37- }
38- else if (week == 7 )
39- {
40- cout << " Sunday" << endl;
41- }
42- else
43- {
44- cout << " Invalid input! Please enter week number between 1-7." << endl;
13+
14+ switch (week){
15+ case 1 :
16+ cout << " Monday" << endl;
17+ break ;
18+ case 2 :
19+ cout << " Tuesday" << endl;
20+ break ;
21+ case 3 :
22+ cout << " Wednesday" << endl;
23+ break ;
24+ case 4 :
25+ cout << " Thursday" << endl;
26+ break ;
27+ case 5 :
28+ cout << " Friday" << endl;
29+ break ;
30+ case 6 :
31+ cout << " Saturday" << endl;
32+ break ;
33+ case 7 :
34+ cout << " Sunday" << endl;
35+ break ;
36+
37+ default :
38+ cout << " Invalid input! Please enter week number between 1-7." << endl;
39+ break ;
4540 }
4641
4742 return 0 ;
You can’t perform that action at this time.
0 commit comments