part1a -...

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

View Full Document Right Arrow Icon
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
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: WRITE(*,'(A)',ADVANCE="NO")"What is the value of x in your function?" 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 "Error: invalid function choice" END SELECT END PROGRAM SUBROUTINE sub(z,x) IMPLICIT NONE REAL, EXTERNAL::z REAL,INTENT(IN)::x WRITE(*,*)"The value of your function at x=",x,"is",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