Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
! Author: Xiaofeng Chen, [email protected]
! Course: CSE 4250, Fall 2017
! Project: project #1, Spread of Epidemics
!https://www.tutorialspoint.com/fortra/fortran_do_while_loop.htm
!helps a lot about the basic of fortran
program mymain
implicit none
real :: n,alp,ga,wn,a,w = 0, cond = 1, e = 2.71828, result
print*,"Enter n and alpha"
read(*,*) n,alp
do while(cond >= 0.001)
wn = w - ((w*(e**w))-(-alp*(e**(-alp)))) / ((w+1)*(e**w))
cond = abs(w-wn)
w = wn
end do
a = w / alp
ga = 1 + w / alp
result = ga * n
if (result - int(result) < 0.5) then
print*, int (result)
else
print*, int (result+1)
end if
end program mymain
program mpadilla26HW04_01
implicit none
integer, DIMENSION(1:4) :: a=(/-2,0,2,4/), array_w, array_T,array_q
integer:: h,g
!Part a
!Real, DIMENSION (1:4):: b=(/-2,0,2,4/)
print*, 'part a= ',a
!Part b
do h=1,4
array_w(h)= 2*(h-2)
end do
print*, 'part b= ', array_w
!Part c
print*,'Enter 4 values'
read (*,*) array_T(1),array_T(2),array_T(3),array_T(4)
print*,'part c=',array_T
!Part d
do g=1,4
array_q(g)= a(4-g+1)
end do
print*, 'part d = ',array_q
end program mpadilla26HW04_01
program mpadilla26HW04_02
implicit none
real, dimension(20):: array_a, array_b=0
integer::z
array_a= (/0.2481, 0.4133, 0.4961,&
0.4618, 0.3686, -0.0495, -0.3477, -0.4219, &
-0.4954, -0.4156, -0.4162,&
0.3258, -0.0574, 0.2749, -0.1003,&
-0.2711, 0.0383, -0.3934, 0.3173, -0.2402/)
do z= 1,20
if (z==1) then
array_b(z)=array_a(z)
else
array_b(z)=array_a(z) + array_a(z-1)
end if
end do
do z= 1,4
print*, '(5F10.4)' , array_b((z-1)*5+1:z*5) !(1:5) (6:10)
end do
end program mpadilla26HW04_02