I haven’t written in Pascal a long time ago, I have set a function and I cannot find an error.

program _1; uses crt; var y:text; minSumEl,n,g:real; i,j,k:integer; f:array[1..6,1..7] of real; m:array[2..13] of real; function OpMiSuElDi(m:array[2..13] of real;i,j,k:integer;f:array[1..6,1..7] of real):real; for k:=2 to 13 do begin m[k]:=0; for i:=1 to 6 do begin for j:=1 to 7 do begin if i+j=k then m[k]:=m[k]+f[i,j]; end; end; if m[k]<result then result:=m[k]; end; begin clrscr; assign(y,'file.dat'); reset(y); g:=0; for i:=1 to 6 do begin for j:=1 to 7 do begin read(y,f[i,j]); write(f[i,j]:4:0); end; writeln; end; minSumEl:=OpMiSuElDi();; writeln('min summa elementov diagonali=',minSumEl:4:0); writeln(' '); for i:=1 to 6 do begin for j:=1 to 7 do begin n:=f[i,j]/3; if (g=0) and (f[i,j]<0) and (frac(n)=0) then begin g:=i; writeln('otrizatelny element kratny 3 v ',i,' stroke'); end; end; end; readkey; end. 

Closed due to the fact that off-topic participants are user194374, Abyx , VenZell , Merlin , Vladimir Martyanov 12 Jan '16 at 20:48 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Community spirit, Abyx, VenZell, Merlin, Vladimir Martyanov
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • what does the compiler say? - yapycoder
  • make a human readable style - Sergey

2 answers 2

  1. The function is defined with arguments, and is called without them. I think, in this case, the definition of arguments is generally not necessary, since "arguments" are already defined as global variables.
  2. No begin after defining a function (remember to add a pair to it end at the end of the function)
  3. Not defined and not initialized result, + its value is not derived from the function

    You did not define the result variable in the function body, but refer to it.

    If this is Delphi, then the function returns the result via result:= , and in simple Pascal you need to assign the function name OpMiSuElDi:=