Home computickets Pascal Write a program for counting the number of items of this...

Pascal Write a program for counting the number of items of this array that have the maximum value

Author

Date

Category

Dan an array of ten integers. Write a program for counting the number of elements of this array that have the maximum value.


Answer 1, Authority 100%

In principle, this is the standard task

Program Test;
const n = 10;
VAR A: Array [1..10] of Integer;
   I, MA, K: Integer;
Begin.
 For i: = 1 to n do begin
  A [I]: = - 2 + Random (4);
  WRITE (A [I], '');
 end;
 Writeln;
 k: = 1;
 MA: = A [1];
 For i: = 2 to n Do Begin
  IF A [I] = MA THEN K: = K + 1
  ELSE.
   IF A [I] & GT; MA THEN
    Begin.
     MA: = A [I];
     k: = 1;
    end;
 end;
 Writeln (k);
end.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions