
ДАЮ 80 БАЛЛОВ ПРОШУ ПОМОГИТЕ Составить программу на языке Паскаль для решения следующей задачи:
Дан одномерный массив. В массиве хранятся оценки по информатике учеников 9 класса. Заполнить массив случайными числами, лежащими в диапазоне от 2 до 5 включительно. Вычислите среднюю оценку в классе по информатике. Входные данные для размерности массива задайте самостоятельно. На проверку нужно прислать текст кода программы, результат работы кода в виде скриншота окна программы с отображением кода и полученного результата. Программная реализация обязательна!

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

Ответ:
program z;
var o:array [1..19] of integer;
i,s:integer;
begin
randomize;
s:=0;
for i:=1 to 19 do
begin
o[i]:=random(4)+2;
write(o[i],' ');
s:=s+o[i]
end;
writeln;
write(s/19:5:3)
end.
Объяснение:
скрин




To solve the given task of calculating the average grade in the 9th-grade computer science class, you can write a Pascal program that generates random grades within the range of 2 to 5 (inclusive) and then calculates the average.
Here's an example Pascal program that accomplishes this task:
```pascal program AverageGrade;
const ARRAY_SIZE = 30; // Define the size of the array (you can change this value as needed)
var grades: array[1..ARRAY_SIZE] of Integer; // Declare the array to store the grades sum, average: Real; // Variables to store the sum and average
i: Integer; // Loop variable
begin Randomize; // Initialize the random number generator
// Fill the array with random grades for i := 1 to ARRAY_SIZE do grades[i] := Random(4) + 2; // Generate a random number between 2 and 5
// Calculate the sum of grades sum := 0; for i := 1 to ARRAY_SIZE do sum := sum + grades[i];
// Calculate the average grade average := sum / ARRAY_SIZE;
// Display the average grade writeln('Average grade in the class: ', average:0:2); end. ```
To run this program, you can use an IDE or compiler that supports Pascal, such as Free Pascal or Turbo Pascal. After running the program, it will display the average grade in the class.
Please note that the program uses a constant `ARRAY_SIZE` to define the size of the array. You can modify this value to match the desired number of grades in the class. Additionally, the program uses the `Randomize` procedure to initialize the random number generator, ensuring different random grades are generated each time the program is run.
Remember to provide the text of the code and a screenshot of the program's output, including the code and the calculated average grade, for submission.
I hope this helps! Let me know if you have any further questions.


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







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