Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- const int maxRange{ 500 };
- int num;
- bool correct{ false };
- int sum{ 0 };
- do
- {
- std::cout << "Enter number maximum 500\n";
- std::cin >> num;
- correct = num < maxRange;
- if (!correct)
- {
- std::cout << "Max range exceeded! Try again!";
- }
- } while (!correct);
- for (; num < maxRange; sum += num++);
- std::cout << "Sum is: " << sum << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment