
Составить программу нахождения суммы чисел -5,-2,1,4...10.Паскаль


Ответы на вопрос

int main()
{
int s=0;
for (int i=-5;i<=10;i+=3)
s+=i;
printf("%d", s);
return 0;
}



Program to Find the Sum of Numbers -5, -2, 1, 4...10 in Pascal
To write a program in Pascal that finds the sum of the numbers -5, -2, 1, 4...10, you can use a loop to iterate through the numbers and accumulate the sum. Here's an example program:
```pascal program SumOfNumbers; var sum, i: integer; begin sum := 0; for i := -5 to 10 do begin sum := sum + i; end; writeln('The sum of the numbers -5, -2, 1, 4...10 is: ', sum); end. ```
In this program, we initialize the variable `sum` to 0. Then, we use a `for` loop to iterate through the numbers from -5 to 10. Inside the loop, we add each number to the `sum` variable. Finally, we display the sum using the `writeln` statement.
When you run this program, it will output:
``` The sum of the numbers -5, -2, 1, 4...10 is: 33 ```
Note: This program assumes that you want to find the sum of the numbers from -5 to 10, inclusive. If you want to exclude certain numbers from the sum, you can modify the loop condition accordingly.
I hope this helps! Let me know if you have any further questions.


Топ вопросов за вчера в категории Информатика
Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili