Fortran·Fortran essentials

Small numerical program

Compute a mean and a filtered sum with arrays.

Intermediate 10 min read Lesson 5 of 150 Challenge included
What you will be able to do
  • Use sum and size.
  • Use where or a loop for filtering.
  • Print formatted output.

In plain English

Compute a mean and a filtered sum with arrays.

  • Use sum and size.
  • Use where or a loop for filtering.
  • Print formatted output.
stats.f90FORTRAN
program stats
  implicit none
  integer :: scores(3) = [90, 85, 72]
  print *, "Average:", sum(scores) / real(size(scores))
  print *, "Passing:", count(scores >= 80)
end program stats
Your turn

Explain it back

Easy

Answer from memory: Which intrinsic counts true elements?

TEXT · starter
Your answer…
Check your understanding before moving on.
Knowledge checkQuestion 1

Which intrinsic counts true elements?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Lesson 5 of 150 · 0% of course