Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!