Saturday 23 December 2017

How to write a simple 'fortran' program?

Programming language is the basic tools for computer data analysis. In the series of post you can learn how to write a fortran program. I have attached some screen shoot to this post.
Let us consider for a simple program, like , sum of two or more data, i.e, y=a+b+c+......

      !progrm for sum
      read(*,*)a,b,c
      y=a+b+c
      write(*,*)y
      stop
      end


Out put
3
2
5
10 (y)

Now another example,
    !program for area of a triangle
      write(*,*)'values of a,b,c'
      read(*,*)a,b,c
      write(*,*)'area'
      s=(a+b+c)/2
      area=sqrt(s*(s-a)*(s-b)*(s-c))
      write(*,*)area
      stop
      end    

Out put
3
4
2
 2.90474(area)

Ok! The above two are very simple and easy program. Now let us see how a computer is organized. We know that computer is a man made machine that was designed same as to a human being in different capacities. The following are very important:-
1. Understand- means what others saying(input).
2. Memory- computer having some memory.      
3. Giving some output.                                              
4. Having some logic and arithmetic calculations abilities. etc...

A computer working with mainly five units , they are- (i) Input unit, (ii) Output unit, (iii) Memory unit, (iv) Arithmetic Logic unit (ALU) and (v) Control unit.

 
All operations performed by a computer are in binary (0 and 1) form. So in binary program is said to be a machine languages. But writing this type (1 and 0 form) of program is very difficult for us. So, programmer's or scientists developed a language, called assembly language. This assembly language program must be translated into a machine language. So it's very easy to writing than binary language. This language is called the high level languages. Examples-FORTRAN, BASIC, PASCAL, COBOL, C , C++ etc. The software used to translate a high level language program into machine language is called Compiler.

Example of a program.

FORmula TRANslation-----FORTRAN.