Q. write a program using fortran to find area using simpson's 1/3 rule
A.
program simp3
implicit none
integer :: n,i
real :: h,y,y1,ylast,s,a
write(*,*) "Enter Number of trems"
read(*,*) n
write(*,*) "Enter Step size"
read(*,*) h
write(*,*) "Enter first term"
read(*,*) y1
write(*,*) "Enter last term"
read(*,*) ylast
s=y1+ylast
do i=2,n-1
write(*,*) "enter y",i,"th term"
read(*,*) y
continue
IF(mod(i,2).EQ.0) then
s=s+4*y
else
s=s+2*y
end IF
end do
a=h*s/3
write(*,*) "area is :- ",a
read(*,*)
end program simp3
A.
program simp3
implicit none
integer :: n,i
real :: h,y,y1,ylast,s,a
write(*,*) "Enter Number of trems"
read(*,*) n
write(*,*) "Enter Step size"
read(*,*) h
write(*,*) "Enter first term"
read(*,*) y1
write(*,*) "Enter last term"
read(*,*) ylast
s=y1+ylast
do i=2,n-1
write(*,*) "enter y",i,"th term"
read(*,*) y
continue
IF(mod(i,2).EQ.0) then
s=s+4*y
else
s=s+2*y
end IF
end do
a=h*s/3
write(*,*) "area is :- ",a
read(*,*)
end program simp3
not working
ReplyDelete