I'm just learning Fortran while exploring the history of programming. This script is a part of my journey to understand how programming languages have evolved over time.
This is a simple calculator program written in Fortran. It supports basic arithmetic operations: addition, subtraction, multiplication, and division.
-
Compile the Fortran source code:
gfortran -o calculator calculator.f90
-
Run the executable:
./calculator
-
Follow the prompts to enter two numbers and an operator.
- Addition (
+
) - Subtraction (
-
) - Multiplication (
*
) - Division (
/
)
Fortran Calculator
Enter first number: 10
Enter second number: 5
Enter the operator (+ - * /): /
Result: 1.00
- Ensure that the second number is not zero when performing division to avoid division by zero errors.
- The program will display an error message for invalid operators.