Day Type
Programming Basics · C++
TASK
Problem
Given the weekday number `d` from 1 to 7, print `weekday` for 1–5 and `weekend` for 6–7.
EXAMPLE
Example
1
weekday
LIMITS
Constraints
1 ≤ d ≤ 7.
LEARN
Theory for this problem
+
An `if` / `else if` / `else` chain checks alternatives from top to bottom. Put more specific or higher-priority conditions first.
Connection to “Day Type”: here, intermediate values are best kept in named variables so the formula stays readable and data types remain clear.
NEED HELP?
Hints
+
['List the possible cases and make them mutually exclusive.', 'After solving “Day Type”, verify the algorithm on your own small example and on an allowed boundary case. Print only the required result with no extra text.']
ANSWER
Solution
+
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
long long n;
cin >> n;
cout << (n <= 5 ? "weekday" : "weekend");
cout << '\n';
return 0;
}