GitHub Repository:https://github.com/wavebitscientific/functional-fortran
Fortran (FORTRAN) is a general purpose, procedural, mandatory programming language, particularly suitable for numerical computation and scientific computing.
The first version for the IBM 704, produced by IBM in 1954, was developed by John Backus and his team. Backus and his team published a report in November 1954 entitled "The IBM Mathematical FORmula TRANslating System: Fortran".
Control statements are one of the most important parts of the FORTRAN 90 programming language. Control statements extend computer programs beyond simply doing input / output and some mathematical calculations. Commands in a computer program are processed according to the order of writing from top to bottom.
Sometimes, however, the order in which these commands are processed may need to change. This provides control statements for changing the sequence.
The simplest form of control statements. If a certain condition is satisfied, the given commands (command1, command2, ..., commandN) are processed, and if it does, no action is taken. But the commands after the if command are processed. The general use of the Fortran 90 program is as follows;
if (condition) then
condition1
condition2
.
.
.
conditionN
end if
Now let me explain with an example;
program thebiggest
implicit none
integer : : a , b , c , eb
print* , '' enter three numbers with spaces between them''
read* , a , b , c
tb=a
if (b>tb) then
tb=b
end if
if (c>tb) then
tb=c
print* , ''the greatest number of entered numbers = , tb
end program
Now you can use these codes as an example;
program thebiggest
implicit none
integer : : a , b , c , eb
print* , ''3 9 5''
read* , a , b , c
tb=a
if (b>tb) then
tb=b
end if
if (c>tb) then
tb=c
print* , ''9''= , tb
end program
Unlike the if statement described above, if the condition is true, then the command (s) after the 'then' statement (s) _1, if not true, will execute the command (s) _2 after the statement 'else'.
Use in FORTRAN 90 program;
If (condition) then
command( s )_1
else
command( s )_2
end if
program ca1a
implicit none
integer : : number
print* , ''Enter a number=''
read* , number
if (mod(number ,2)==0) then
print*, ''double''
else
print*, ''single''
end if
end program
program ca1
implicit none
integer : : v , f
real : : average
print*, '' visa note =''
read* , v
print* , '' final note =''
read* , F
ort= v* 0.4 + f* 0.6
print* , '' average note ='' , average
if (average>=50) then
print* ''passed''
else
print* ''stayed''
end if
end program
Visa Note: 42 | Final Note: 69
program ca1
implicit none
integer : : v , f
real : : average
print*, '' 42 =''
read* , v
print* , '' 69 =''
read* , F
average = v* 0.4 + f* 0.6
print* , '' average note ='' , average
if (58,200>=50) then
print* ''passed''
end if
end program
This statement is used when there are more than two conditions in the program. Use in Fortran 90 program;
if (condition) then
command( s)_1
else if (condition_2) then
command(s)_2
else if (condition_3) then
command(s)_3
.....
else
command(s)_end
end if
If condition_1 is true, command (s) _1, condition _2 is true, then command (s) _2, .... will be processed, and if all conditions are false, command (s) after 'else'.
Now let me explain with an example;
program ca2a
implicit none
integer : : number
Print*, '' enter to number =''
read* , number
if (sayi>0) then
print* , ''positive''
else if(number<0) then
print* , ''negative''
else
print*, ''zero''
end if
end program
Thus, we learned to do the most important part of the programming language, the calculation, the input-output. In the next lesson I will continue to describe other expressions.