Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Change the following two programs in Pascal form: PROGRAM #1 Simple Fortran Code PROGRAM Simple REAL :: a, b, c, d character (LEN=3) :: r='si'

Change the following two programs in Pascal form:

PROGRAM #1 Simple Fortran Code

PROGRAM Simple

REAL :: a, b, c, d

character (LEN=3) :: r='si'

DO WHILE ( r .EQ. 'si')

PRINT *, 'Enter variable A: '

READ(*,*) a

PRINT *, 'Enter variable B: '

READ(*,*) b

PRINT *, 'Enter variable C: '

READ(*,*) c

d = b*b - 4.0*a*c

IF (d <0.0) THEN

WRITE(*,*)'It is not real: ', d

ELSE IF (d >= 0.0) THEN

WRITE(*,*)'It is real: ', d

END IF

PRINT *, 'Do you wish to continue: '

READ(*,*) r

END DO

PRINT *, 'Program finished '

END PROGRAM Simple

---------------------------------------------------

PROGRAM #2 Subroutine Fortran Code

Program Sub

REAL :: a, b, c,d,r1,r2

PRINT *, 'Enter variable A: '

READ(*,*) a

PRINT *, 'Enter variable B: '

READ(*,*) b

PRINT *, 'Enter variable C: '

READ(*,*) c

CALL Roots(a, b, c, d, r1, r2)

CALL Print(r1, r2, d)

END Program Sub

SUBROUTINE Roots(a, b, c, d, r1, r2)

d = b*b - 4.0*a*c

IF (d <0.0) THEN

WRITE(*,*)'Doesnt contain real square root.'

STOP

ELSE IF (d >= 0.0) THEN

d = SQRT(d)

r1 = (-b + d)/(2.0*a)

r2= (-b - d)/(2.0*a)

END IF

RETURN

END

SUBROUTINE PRINT(r1, r2, d)

IF (r1 == r2) THEN

PRINT*,'The following square root is; ', root1

ELSE IF (r1 /= r2) THEN

PRINT*,'The square root is ', r1, ' y ', r2

END IF

PRINT*,'The discriminant is ', d

RETURN

END

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions

Question

Why doesn't cholera toxin cause cancer?

Answered: 1 week ago