Arithmetic Operations

Programming

This program demonstrates all basic arithmetic operations in Fortran: addition, subtraction, multiplication, and division.

Arithmetic Operators

Implementation

program arithmetic_operations
    implicit none
    integer, parameter :: dp = kind(1.0d0)
    real(dp) :: a, b, sum, difference, product, quotient

    a = 12.5_dp
    b = 3.5_dp
    sum = a + b
    difference = a - b
    product = a * b
    quotient = a / b

    print *, "Sum: ", sum
    print *, "Difference: ", difference
    print *, "Product: ", product
    print *, "Quotient: ", quotient
end program arithmetic_operations

Output

Sum:    16.000000000000000
Difference:     9.0000000000000000
Product:    43.750000000000000
Quotient:    3.5714285714285716