# You are given an array of n integers and an integer b. How many times does the number b appear in the array?

August 31, 2021 | education

| program zz1;

const n = 20; // set the number of elements in the array

var mas: array [1..n] of integer;

i, k, b: integer;

begin

read (b); // enter the given number

for i: = 1 to n do

mas [i]: = random (21) +1; // enter numbers into the array randomly from 1 to 20

for i: = 1 to n do

write (mas [i], ”); // display the numbers from the array to the screen

writeln; // go to a new line for output

for i: = 1 to n do

if mas [i] = b then k: = k + 1; // check if the number from the array is equal to the given one, then count this number

write (‘the number of elements equal to the given number -‘, k); // display the answer

end.