I
I
idzphoenix2019-06-04 16:57:33
Pascal
idzphoenix, 2019-06-04 16:57:33

Pascal ABC - how to do it?

The user enters an array of real numbers, the size of a one-dimensional array is given by a constant .
You need to determine how many numbers in the array are non-integer.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stockholm Syndrome, 2019-06-04
@StockholmSyndrome

const N = 5; 
var
  i, j, s: Integer; 
  nums: array[1..N] of Real; 
begin
  for i := 1 to N do begin 
    ReadLn(nums[i]);
  end;
  
  s := 0; 
  for j := 1 to N do begin 
    if Frac(nums[j]) <> 0 then begin 
      s := s + 1;
    end;
  end;
  
  WriteLn(s);
end.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question