You are given an array of natural numbers, given at random from the range from 0 to 255

You are given an array of natural numbers, given at random from the range from 0 to 255 and the number X from the same range. The length of the array is N. If the number X is in the array, then calculate the sum of the array elements from the first occurrence of this number to the end of the array. Solve the problem for N = 10.

program zz1;
const n = 10; // set the number of elements in the array
var i, x, k, j, s: integer; // set variables of integer type
m: array [1..n] of integer;
begin
write (‘enter the given number X’);
read (x);
for i: = 1 to n do // get n random numbers and write them into an array
m [i]: = random (256);
for i: = 1 to n do // display the resulting array on the screen
write (m [i], ”);
writeln; // go to a new line to display the response
for i: = 1 to n do
if m [i] = x then k: = i;
if k = 0 then writeln (‘there are no elements equal to the given one’) // print the answer
else
begin
for j: = k to n do s: = s + m [i];
write (‘the sum of elements from x to the end =’, s);
end;
end.



One of the components of a person's success in our time is receiving modern high-quality education, mastering the knowledge, skills and abilities necessary for life in society. A person today needs to study almost all his life, mastering everything new and new, acquiring the necessary professional qualities.