benchmarks.wiki / Public workspace

MMLU-Pro / 10505 / Write a FORTRAN program to compute the arithmetic mean of N real numbers. You…

Problem

Answer published by the source. Consult the official source to check your work against its answer.

question

Write a FORTRAN program to compute the arithmetic mean of N real numbers. You may assume that the numbers have been read into an array X having members X(1), X(2),..., X(N).

category

computer science

options

  1. DIMENSION X(N) SUM = 0.0 READ (5,20) N, (X(I), I=1,N) DO 50 I = 1,N 5\OSUM = SUM + X(N-I+1) AVG = SUM/FLOAT (N) STOP END
  2. DIMENSION X(1:N) SUM = 0.0 READ (5,20) N FOR I = 1 TO N SUM = SUM + X(I) NEXT I AVG = SUM/FLOAT (N) PRINT *, AVG END
  3. DIMENSION X(N) SUM = 0.0 READ (5,20) N 2\OFORMAT (2X,I5) DO 50 I = 1,N SUM = SUM + I AVG = SUM/FLOAT (N) STOP END
  4. DIMENSION X(N) SUM = 0.0 READ (5,20) (X(I), I=1,N) DO 50 I = 1,N 5\OSUM = SUM + X(I) AVG = SUM/N STOP END
  5. DIMENSION X(N) SUM = 0.0 READ (5,20) N 2\OFORMAT (2X,I5) DO 50 I = 1,N 5\OSUM = SUM - X(I) AVG = SUM/FLOAT (N) STOP END
  6. DIMENSION X(N) SUM = 0.0 READ (5,20) N 2\OFORMAT (2X,I5) DO 50 I = 1,N 5\OSUM = SUM + X(I) AVG = SUM/FLOAT (N) STOP END
  7. DIMENSION X(N) SUM = 1.0 READ (5,20) N 2\OFORMAT (2X,I5) DO 50 I = 1,N 5\OSUM = SUM + X(I) AVG = SUM/FLOAT (N) STOP END
  8. DIMENSION X(N) SUM = 0.0 READ (5,20) N 2\OFORMAT (2X,I5) DO 50 I = 1,N SUM = SUM + X(I)^2 AVG = SQRT(SUM/FLOAT (N)) STOP END
  9. DIMENSION X(N) SUM = 0.0 READ (5,20) N 2\OFORMAT (2X,I5) DO 50 I = 1,N 5\OSUM = SUM + X(I) AVG = SUM/INT (N) STOP END
  10. DIMENSION X(N) SUM = 0.0 WRITE (5,20) N 2\OFORMAT (2X,I5) DO 50 I = 1,N 5\OSUM = SUM + X(I) AVG = SUM/FLOAT (N) STOP END

src

stemez-ComputerScience

Discussion

Discussion

No discussion posts on this page yet. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

Source and history

Official source

initial import