Given an array of real numbers containing 25 elements, calculate the sum of the array elements
Given an array of real numbers containing 25 elements, calculate the sum of the array elements starting from the first element and the maximum array element inclusive
program zz1;
const n = 25; // set the number of numbers in the array
var i, p: integer; // set a variable of integer type
max, s: real;
x: array [1..n] of real;
begin
for i: = 1 to n do // organize a loop in which we enter n given numbers from the keyboard into the array
read (x [i]);
for i: = 1 to n do
if x [i]> max then begin max: = x [i]; p: = i; end; // check if the array element is greater than the maximum, then write it to the maximum and remember its number
for i: = 1 to p do
s: = s + x [i]; // find the amount
write (‘received sum =’, s: 5: 2); // display the resulting amount in the format of five digits for a number and two decimal places
end.