Menu Close

Absolute Value – FORTRAN

In Fortran, the absolute value of a number can be obtained using the ABS function.

The ABS function returns the absolute value of its argument.

 

Example

program AbsoluteValueExample
  implicit none

  integer :: x
  real :: y

  x = -10
  y = -3.14

  write(*,*) "Absolute value of x:", ABS(x)
  write(*,*) "Absolute value of y:", ABS(y)

end program AbsoluteValueExample

More Related Stuff