I\'m having trouble writin this into a Fortran Code, please help Given the array
ID: 3684368 • Letter: I
Question
I'm having trouble writin this into a Fortran Code, please help
Given the array of angles tehta_n= pi/n, n= 2. 3... 9. Generate a script that computes cos0n and displays the results as cos(pi/S) = 0.33565; (pi/5)=20.000 degrees cos(pi/8) = 0.52388; (pi/8)=22.500 degrees cos(pi/7) = 0.50057; (pi/7)=25.714 degrees cos(pi/6) = 0.86603; (pi/6)=30.000 degrees cos(pi/5) = 0.80502; (pi/5)=36.000 degrees cos(pi/4) = 0.70711; (pi/4)=45.000 degrees cos(pi/3) = 0.50000; (pi/3)=60.000 degrees cos(pi/2) = -0.00000; (pi/2)=50.000 degreesExplanation / Answer
main.f95
program arrayProg
real, parameter :: pi = 180
real :: numbers(8) !one dimensional integer array
real :: a(8)
real :: x(8)
!assigning some values to the array numbers
do i=2,9
numbers(i) = pi/i
end do
do i=2,9
numbers(i) = pi/i
a(i) = numbers(i)*3.14159/180
x(i) = cos(a(i))
write(*,*) 'cos(pi/',i,')=', x(i),'; pi/',i,'=', numbers(i),'degrees'
end do
end program arrayProg
Output :
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.