part1a -...

This preview shows page 1. Sign up to view the full content.

PROGRAM part1a USE lab8mod IMPLICIT NONE !declare variables REAL::x CHARACTER:: func !print menu showing choice of functions WRITE(*,*)"Choose from the following functions:" WRITE(*,*) "f(x) = x+1" WRITE(*,*) "g(x) = x^2 + 2x + 1" WRITE(*,*) "h(x) = x^3 + 3x^2 + 3x + 1" WRITE(*,*) "i(x) = cos(x)" WRITE(*,*) "j(x) = e^2x" WRITE(*,*) "k(x) = log(x)" WRITE(*,*) WRITE(*,*)". ...................................... " WRITE(*,*) READ(*,*) func WRITE(*,*) !read in value for x
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: WRITE(*,'(A)',ADVANCE=&quot;NO&quot;)&quot;What is the value of x in your function?&quot; READ(*,*) x SELECT CASE(func) CASE('F','f') CALL sub(f,x) CASE('G','g') CALL sub(g,x) CASE('H','h') CALL sub(h,x) CASE('I','i') CALL sub(i,x) CASE('J','j') CALL sub(j,x) CASE('K','k') CALL sub(k,x) CASE DEFAULT STOP &quot;Error: invalid function choice&quot; END SELECT END PROGRAM SUBROUTINE sub(z,x) IMPLICIT NONE REAL, EXTERNAL::z REAL,INTENT(IN)::x WRITE(*,*)&quot;The value of your function at x=&quot;,x,&quot;is&quot;,z(x) END SUBROUTINE...
View Full Document

This note was uploaded on 07/22/2010 for the course MAE 112 taught by Professor Freeh during the Spring '10 term at North Country Community College.

Ask a homework question - tutors are online