FORTRAN PROGRAM EXERCISE
1. 1. Fortran
programme to find the average of five numbers
program
keska
!program
to find average scores of five students
implicit
none
real::student1,student2,student3,student4,student5,average,total
print*,'Enter
the first student score';read*,student1;print*,' '
print*,'Enter
the second student score';read*,student2;print*,' '
print*,'Enter
the third student score';read*,student3;print*,' '
print*,'Enter
the fourt student score';read*,student4;print*,' '
print*,'Enter
the fifth student score';read*,student5;print*,' '
total=student1+student2+student3+student4+student5
print*,'Total
students scores = ',total;print*,' '
average=total/5
print*,'The
Average scores is',average
end
program keska
2. 2. Fortran
program to find the root of quadratic equation
program
KENNY
!program
to find roots of quadratic equation
implicit
none
real
::a,b,c,t,u
print*,'Enter
the value for a here';read*,a;print*,' '
print*,'Enter
the value for b here';read*,b;print*,' '
print*,'Enter
the value for c here';read*,c;print*,' '
t=(b*b-4*a*c)
if
(t>0) then
u=sqrt(t)
print*,'First root = ',(-b-u)/(2*a);print*,'
'
print*,'Second root = ',(-b+u)/(2*a)
elseif (t<0) then
u=sqrt(-t)
print*,'Real part is',-b/(2*a);print*,' '
print*,'Imaginary part is',u/(2*a)
elseif (t==0) then
print*,'Double root',-b/(2*a)
endif
end program KENNY
Note:
you can copy the code and paste them on your compiler, please try to study the
code and ask anything that is not clear..
No comments:
Post a Comment