# Fortran Interview Questions

## An Overview of Fortran

Fortran word was derived from Formula Translation. Fortran was developed by John Backus and IBM in the year 1957. It was designed for scientific and numeric applications. In simple words it was designed to allow easy translation of the math formulas into the code Fortran ruled for almost half a century in areas of computational physics and chemistry, numerical weather prediction, computational fluid dynamics and many more. Fortran is the first widely used high-level programming language. The first version of Fortran was released as a programming tool for the IBM 704 computer in 1957.

The **Fortran interview questions** we are mentioning below will help you to gain enough of the knowledge about Fortran.

### Advantages

- Fortran supports Numerical analysis and scientific computation
- Fortran supports the Generic and Structured programming
- Fortran supports Array and the Modular programming
- High performance
- Object-oriented programming
- Extremely optimized for the vectorization
- Fortran is readable and easy to understand
- Very fast in Scientific Computing

All your questions related to team leader will be answered in the **Fortran interview questions** mentioned below

#### Latest Version:-

The newest version of Fortran is Fortran 2018 which was released on November 28, 2018

### Most Frequently Asked Fortran Interview Questions And Answers With Examples:

- What is Fortran? Explain
- Why we used Fortran language?
- What are the advantages of Fortran Programming language?
- Who developed Fortran programming language?
- Explain double precision in Fortran?
- What do you mean by the array in Fortran?
- Explain the basic data types in Fortran?
- Why is Fortran faster than C? Explain
- Write a program to print “Welcome Bestinterviewquestion.com” in Fortran?
- How to define a function in Fortran?
- What do you mean by a subroutine in Fortran?
- What do you mean by the module in Fortran?
- What do you mean by implicit none in Fortran?
- What is cmplx() in Fortran?
- Explain the reserved keywords available in Fortran?
- How to declare variables in Fortran?

Fortran stands for FORmula TRANslation.Fortran is the first widely used high-level programming language. Fortran language is used for doing high-level scientific computing, and until today it is one of the widely used languages for this purpose. Fortran was release in the year 1957 which 62 years now. The popular language BASIC is based on Fortran II.

Fortran is nowadays used very rarely but for numerical simulation and large scale, for example, to use it compute scientifically, Fortran has always been a choice of programmers that’s the only reason why it is known as the sophisticated simulation code that is written in Fortran.

##### Some of the advantages of Fortran are:-

- Fortran supports Numerical analysis and scientific computation
- Fortran supports the Generic and Structured programming
- Fortran supports Array and the Modular programming
- High performance
- Object-oriented programming
- Extremely optimized for the vectorization
- Fortran is readable and easy to understand
- Very fast in Scientific Computing

Fortran was developed by John Backus and IBM in the year 1957.

Every computer is limited in magnitude and precision. REAL has a specific number of significant digits. If for a calculation number of significant digits are required then DOUBLE PRECISION is used. For a 32-bit computer range REAL number can be up to 7 decimal digits and will have a magnitude ranging from 10-38 to 10+38. Now, DOUBLE PRECISION REAL numbers have the size ranging from 10-308 to 10+308 and twice the number of decimal digits.

**Point to be noted**: Go through this Q&A very thoroughly as this is one of the essential **Fortran interview questions**.

An array is the collection of datatype or variables. An array is stored in a consecutive memory location. Mostly array is used to store the same data types. In Fortran, up to 7-dimensional arrays can be created. Here the arrays are declared with dimension attribute.

**Syntax**:- `Datatype, dimension() :: Array Name`

##### Fortran provides five data types:-

**Integer type**:- It stores only the integer values.**Real type**:- It holds the decimal point numbers such as 3.0, 2.1415, -200.587, etc.**Complex type**:- it holds the complex numbers like (2.0, -4.0) and that equals to 2.0 – 4.0i**Logical type**:- it stores only true and false**Character type**:- it holds the characters and strings

Fortran is faster than C in case of numerical tasks. During the execution of the mathematical functions, Fortran handles memory references very well. In C pointers are challenging to optimize while doing mathematical tasks. The Matlab and Numpy are still till date written in Fortran.

#### Example

` `**Syntax:-**

function name(arg1, arg2, ....)

[declarations, including those for the arguments]

[executable statements]

end function [name]

When a programmer writes the subroutine statement in a program, then subroutine can modify its arguments, but it does not return a value.

#### Example

` ``subroutine name(arg1, arg2, ....)`

[declarations, including those for the arguments]

[executable statements]

end subroutine [name]

**A subroutine is invokes using the call statement.**

While writing a big program or if the functions and subroutines need to be used in more than one program then the programmer use module. A module is like a complete package where a programmer can keep the functions, subroutines. A module basically splits the program into multiple files.

##### A module contains two parts-

- a specification part for the statements declaration
- a includes a section for the subroutine and the function definitions

This is the favorite interviewer question in **Fortran interview questions**.

#### Example

` ``module name`

[statement declarations]

[contains [subroutine and function definitions] ]

end module [name]

In Fortran, there is a feature of Implicit typing which means there is no need of declaring the variables before the use of the variables so the first letter of the variable name will determine the type of the variable. i, j, k, l, m, n are taken as integer numbers and other as real numbers.

The excellent programming practice is that the variables should be declared at the starting of the program so implicit none statement disables the implicit typing so that variables can be announced at the starting of the program

A number are those number s which has two parts real number and an imaginary number. Cmplx() function in Fortran creates a complex number. Cmplx() function produces a result where the real and the imaginary parts are the single precision regardless of the type of the input arguments.

Reserved words are those words which cannot be identifiers. Fortran has no reserved words, but Fortran has identifiers like END, PROGRAM, DO.

The variables in Fortran is declared by using the type statement at the beginning of the program. The syntax for declaring a variable is:-

##### type-specifier :: list

Here type-specifier can be: -INTEGER, REAL, COMPLEX, LOGICAL AND CHARACTER and the list is the name of the variables that can be separated with commas

##### For example:-

- INTEGER:: Total, Mean
- REAL:: Average
- CHARACTER(10) :: Surname, Name

((10 is the length value that must be there with the CHARACTER specifier. CHARACTER specifier can hold the string not more than 10 characters))