CS 430 – Quiz #1

Name _________________________                                    Section 1 : __2:00___

 

Given the following FORTRAN code

NUMBER =  23

REAL1 = 41.2

REAL2 = 567.432

Write the FORTRAN statement(s) that would output the numbers all on one line with 1 space between them.

 

 

              WRITE (6, 10) NUMBER, REAL1, REAL2

10                  FORMAT (1X, I2, 1X, F4.1, 1X, F7.3)

10                  FORMAT (1X, I2, F5.1, F8.3)

10         FORMAT (1X, I2, ‘ ‘, F4.1, ‘ ‘, F7.3)

 

 

Write the formula for computing the address of  an element in a one-dimensional Pascal array

 

baseAddress + ( index – lowerBound) * size

 

 

Use the formula you wrote above to compute the address of  A[23] where

 

 

1000 + (23-(-3)) * 3 = 1000+(23+3) * 3  = 1000+ 26*3 = 1000 + 78 = 1078

 

 

 

What will be output when the following Snobol code is run?

 

Colors = “orange” | “black” | “green”

turn at the black house”  Colors . Result

Output = result

Instructions = “turn at the orange house”

Instructions Colors = “strange”

Output = Instructions

 

black

turn at the strange house