Challenge: Weekend or Weekday
Completed
Define enum Day { MON = 1, TUE, WED, THU, FRI, SAT, SUN };. Read a day number (1–7) and print weekend if it is SAT or SUN, otherwise weekday.
Input
One integer from 1 to 7.
Output
weekend or weekday.
Example
Input
6
Output
weekend
Editor
C
Hints
MON = 1 makes the following names 2, 3, ... 7.
Compare d with SAT and SUN.
Solution explanation
The enum names make the condition read like plain English.
Show solution
#include <stdio.h>
enum Day { MON = 1, TUE, WED, THU, FRI, SAT, SUN };
int main() {
int d;
scanf("%d", &d);
if (d == SAT || d == SUN) {
printf("weekend\n");
} else {
printf("weekday\n");
}
return 0;
} Output
Answer
You can practice without logging in. Log in to save completion.
Save your progress
You're practising as a guest, so your progress won't be saved.
- Track every lab you complete
- Earn verifiable lab certificates
- See your progress in every module