Вопрос задан 02.05.2019 в 04:36. Предмет Информатика. Спрашивает Романова Софья.

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

четных и нечетных элементов.
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Орлова Арина.
Var a : array [1..10] of integer;
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.

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

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.

0 0

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос