Website Summary Files Commits Branches @commit @diff @stats
path: root / Week04 / Exercise09.cpp
blob: 5a8f08bd3b5568ccae56cb7113a9f50d8ea912c1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>

int main() {
    unsigned int max_number;
    std::cin >> max_number;

    unsigned int even_sum = 0;
    unsigned int odd_sum = 0;

    for (unsigned int current_number = 1; current_number <= max_number; current_number++) {
        if (current_number % 2 == 0) {
            even_sum += current_number;
        }
        else {
            odd_sum += current_number;
        }
    }

    std::cout << even_sum << ' ' << odd_sum;

    return 0;
}