Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- setlocale(LC_ALL, "ru");
- int begin;
- int end;
- cout << "Введите начало диапазона: ";
- cin >> begin;
- cout << "Введите конец диапазона: ";
- cin >> end;
- int sum = 0;
- int i = begin;
- while (i <= end) {
- if (i % 2 == 1) {
- sum += i;
- }
- i++;
- }
- cout << sum << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment