
Cоставить программу в паскале. В одномерном массиве произвольных чисел вычислить произведение
четных и нечетных элементов.

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

I, p1, p2: integer;
Begin
I:=1;
P1:=1; p2:=1;
For i := 1 to 10 do a[i] := random(10);
While i<=10 do begin
If i mod 2 <> 0 then p1:=p1 *a[i] else p2:= p2 * a[i];
I := i +1;
End;
Write(p1,' ',p2)
End.



Program in Pascal to Calculate the Product of Even and Odd Elements in a One-Dimensional Array
Sure, I can help you with that. Below is a program in Pascal to calculate the product of even and odd elements in a one-dimensional array:
```pascal program CalculateProduct;
const MAX = 100;
var arr: array[1..MAX] of integer; n, i: integer; productEven, productOdd: integer;
begin write('Enter the number of elements in the array: '); readln(n);
write('Enter the elements of the array: '); for i := 1 to n do read(arr[i]);
productEven := 1; productOdd := 1;
for i := 1 to n do begin if arr[i] mod 2 = 0 then productEven := productEven * arr[i] else productOdd := productOdd * arr[i]; end;
writeln('Product of even elements: ', productEven); writeln('Product of odd elements: ', productOdd);
end. ```
In this program, we declare a one-dimensional array `arr` to store the input elements. We then prompt the user to input the number of elements and the elements themselves. After that, we calculate the product of even and odd elements separately using a loop and display the results.
I hope this helps! Let me know if you have further questions or need additional assistance.


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