Commit 18c2eee2 authored by mary.zaqaryan's avatar mary.zaqaryan

Mary Zaqaryan Exercise_05_05 Version2

parent e1f8afe5
......@@ -4,25 +4,24 @@ int
main()
{
int amount;
std::cout << "Enter the amount of numbers." << std::endl;
std::cout << "Enter the amount of numbers.";
std::cin >> amount;
if (amount <= 0) {
if (amount < 0) {
std::cerr << "Error 1: amount can't be negative or equal 0.";
return 1;
}
int sum = 0;
for (int i = 1; i <= amount; i++) {
for (int i = 1; i <= amount; ++i) {
int number;
std::cout << "Enter number." << std::endl;
std::cout << "Enter number.";
std::cin >> number;
sum += number;
}
std::cout << "Sequence of integers is: " << sum << std::endl;
std::cout << "Sequence of integers is " << sum << std::endl;
return 0;
}
Enter the amount of numbers.
Enter number.
Enter number.
Enter number.
Enter number.
Enter number.
Sequence of integers is: 1500
Enter the amount of numbers.Enter number.Enter number.Enter number.Enter number.Enter number.Sequence of integers is 1500
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment