0% found this document useful (0 votes)
14 views

Cosc 202 P Q

The document contains tutorial questions about FORTRAN programming. It covers topics like data types, operators, functions, program structure and syntax. Multiple choice questions test understanding of concepts like program flow, arithmetic operations, and intrinsic functions.

Uploaded by

Richard
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Cosc 202 P Q

The document contains tutorial questions about FORTRAN programming. It covers topics like data types, operators, functions, program structure and syntax. Multiple choice questions test understanding of concepts like program flow, arithmetic operations, and intrinsic functions.

Uploaded by

Richard
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Edited By: MR.

ABDOUL

COSC 202 TUTORIAL QUESTIONS


1. Which of the following is not a function of the 7. The following are called RELATIONAL
Central Processing Unit OPERATORS in Fortran <, >, = =, >=, <=
a. Coordinates the activities of the computer TRUE ~ FALSE
b. Accept data into the computer ~ 8. What is the output of this program
c. Perform the calculations of the computer REAL :: a
d. Store a small amount of data and INTEGER :: b
instructions INTEGER result = a+b
2. Which of the following statement is not true of A = 5.0
a main memory B= 3.5
a. It is larger than the Registers WRITE (*,*) result
b. Smaller than the hard drive END
c. It temporarily stores the program currently a. 8.5
being run by the computer b. 8.0
d. It is non-volatile ~ c. 8 ~
3. The function of Compilers and Linkers is to d. 9.0
a. Write Programs 9. The following are examples of predefined
b. Convert Programs to machine language ~ FORTRAN functions except
c. Make programs free of errors a. ABS()
d. Keep programs run faster b. PI() ~
4. FORTRAN is an acronym for c. SQRT()
a. Formular Transition d. SIN()
b. Formular Transciber 10. The code block below will perform one of the
c. Formular Translator ~ following operations
d. None of the above PROGRAM Testing
5. What is the first line of every FORTRAN INTEGER :: I = 1, N=5
program INTEGER result Do K= 1, N
a. PROGRAM ~ result = result*I
b. REAL END DO
c. INTERGER WRITE (*,*) result
d. All of the above END
6. What among the following keyword is used to a. Factorial(5)~
define a numeric constant in FORTRAN b. Summation(5)
a. PARAMETER ~ c. PerimeterOfRectangle(5)
b. INTEGER d. AreaOfCircle(5)
c. DIMENSION 11. How many times does the code write?
d. REAL DO I = 1,3
Edited By: MR. ABDOUL

DO J = 1,3 PROGRAM PRINT1


WRITE (*,*) J*I IMPLICIT NONE
END DO INTEGER x, y, i
END DO INTEGER, DIMENSION(10) :: lis
a. 1 DO I = 1, 10 X= I * 2
b. 2 lis(i) = x
c. 3 END DO
d. NONE OF THE ABOVE ~ WRITE (*,*) lis
12. Any characters following exclamation mark END PROGRAM PRINT1
(!) (except in a character string) is a a. 0
a. Comment ~ b. 1 ~
b. Variable c. 10
c. Function d. 2
d. Subroutine 17. Which among the following is not a valid
13. Which of the following is not an example of the FORTRAN inbuilt function
Fortran intrinsic data type a. COSINE(90) ~
a. INTEGER b. SQRT(25.0)
b. REAL c. MAX(30,10)
c. COMPLEX d. None of the above
d. None of the above ~ 18. The output of the program above is give as
14. Every variable name in Fortran must start with PROGRAM quadequ
a number REAL :: A = 1.0, B = 6.0, C = 9.0
TRUE FALSE ~ REAL X1. X2 !Real roots
15. What is the output of the program below X1 = (-B+ (SQRT(B**2 - 4*A*C))) /
INTEGER:: x=0, step=1 2.0*A)
DO X2 = (-B- (SQRT(B**2 - 4*A*C))) / 2.0*A)
IF (x = =5 ) EXIT WRITE(*,*) ‘First Root:’, X1
IF (x = =5 ) THEN WRITE(*,*) ‘Second Root:’, X2
WRITE (*,*) x END IF x = x + step END PROGRAM quadequ
END DO a. 6.0, - 6.0
END b. 7.0, -7.0
a. 1 c. 3.0 -3.0 ~
b. 2 d. 9.0 -9.0
c. 3 19. The output of this program
d. No Output ~ PROGRAM quadequ
16. How many LINES of character output is INTEGER :: A = 1, B = 6, C = 9
printed by the program above REAL X1. X2 !Real roots
Edited By: MR. ABDOUL

X1 = (-B+ (SQRT(B**2 - 4*A*C))) / 2.0*A) lis(i) = x


X2 = (-B- (SQRT(B**2 - 4*A*C))) / 2.0*A) END DO
WRITE(*,*) ‘First Root:’, X1 WRITE (*,*) lis
WRITE(*,*) ‘Second Root:’, X2 END PROGRAM PRINT1
END PROGRAM quadequ The number of iterations performed in the program
a. 6.0, - 6.0 above is
b. 3.0 -3.0 ~ a. 0
c. 9.0 -9.0 b. 5
d. None of the above c. 10 ~
20. Which among the following is the result of d. 2
evaluating the expression 10 * 5 + 100 / 10 – 5 24. PROGRAM PRINT1
+7%2 IMPLICIT NONE
a. 56 ~ INTEGER x, y, i
b. 69 INTEGER, DIMENSION(10) :: lis
c. 104 DO I = 1, 10 X= I * 2
d. 58 lis(i) = x
21. Fortran 90 is case sensitive END DO
TRUE FALSE ~ WRITE (*,*) lis
22. Executing the program below with FORTRAN END PROGRAM PRINT1
90 compiler will result to a syntax error How many LINES of character output is printed by
PROGRAM examstatus the program above
REAL:: totalscore = 10 a. 0
CHARACTER(LEN = 10) REMARK b. 1 ~
IF(totalscore >= 50) THEN c. 10
remark = ‘PASS’, d. 2
ELSE 25. A Fortran statement too long to fit in a single
remark = ‘FAIL’ line may be continued on the next line by
END IF ending the current line with
WRITE (*,*) remark a. & (ampersand) ~
END PROGRAM examstatus b. ! (exclamation)
TRUE FALSE~ c. $ (dollar)
23. PROGRAM PRINT1 d. None of the above
IMPLICIT NONE 26. Which of the following is not an example of a
INTEGER x, y, i Fortran Real Number
INTEGER, DIMENSION(10) :: lis a. 10.
DO I = 1, 10 b. 1.0E-3
X= I * 2 c. -12.0E1.5 ~
Edited By: MR. ABDOUL

d. -9465.6 32. Which of the following is a limitation of an


27. Which of the following is not a correct Integer data type?
FORTRAN statement? a. It is impossible to represent very large
a. x = y * z positive or very small negative integers. ~
b. m = 2 * (62 / - 2) ~ b. Only very large positive or very small
c. y = a – b/5/3 negative integers are represented
d. none of the above c. It only allows very large positive integers to
28. What will be printed by the following statement represented
Do I = 5, 20, 5 num = i/5 d. It only allows very small negative integers
End do to represented
Write(*,*) num 33. Which one of the following is true of integer
a. Num data type
b. 4 ~ a. Integer should never be used to calculate
c. 1 2 3 real-world quantities ~
d. none of the above b. They are used to calculate real-world
29. Write (*, 10) y quantities
10 format (I6) c. They are numbers with decimal point
Which of the following will be printed with this d. They are always enclosed in a single or
format double quotation mark
a. 1000000 34. Which of the following is true about
b. Kaduna FORTRAN declaration
c. 899 ~ a. It always starts with a variable name
d. None of the above b. It always begin with two colons
30. Which option explain what the format c. It always begin end two colons
statement format (4f9.5) represent d. It always begin with the data type
a. 9 real numbers 35. Which of the following is a correct exponential
b. A number with 9 width with 4 place of representation?
decimal a. 767.4
c. 4 numbers with width 9 and 5 place of b. 18.67E3.6
decimal ~ c. 15E10
d. None of the above d. 52.567E-7 ~
31. The value of the 3**3.0*(4.0 – 1) + 2.0 * 1 * 36. The following are true for a FORTRAN
3.0 is character string except
a. 87.0 ~ a. Must be enclosed between single or double
b. 24.0 quotes
c. 60.0
d. none of the above
Edited By: MR. ABDOUL

b. The content of a string consist of all INTEGER:: Senegal= 2, Congo= 3


characters and spaces included between the Limpopo = Nile* Niger ** (Congo – Senegal)
quotes Write (*,*) Limpopo will write which of the
c. The length of the string is the number of following values?
characters of its content. a. 13.8 ~
d. They consist of only alphabetic characters ~ b. 13.0
37. The value for the following arithmetic c. 13
expression 14.0/5*(2*(7-4)/4) **2 is d. 14
a. 2.0000 42. Which of the following initializes the variable
b. 2.8000 ~ p = 20.0 q = 5.3 r = 6.5
c. 8.000 a. REAL:: p = 20.0, r = 6.5, q = 5.3 ~
d. 2.8500 b. REAL, p = 20, r = 6.5, q = 5.3
38. One of the following is a valid FORTRAN c. REAL; p = 20 ; r = 6.5 ; q = 5.3
identifier d. REAL: p = 20.0: u = 6.5; m = 5.3
a. 10_Cloves 43. Values can be put into a variable through the
b. Black.Pepper following except
c. Cannyen Pepper a. Initializing it when the program is run
d. Black_Seed ~ b. Using a READ statement
39. Which of the following is a rule for forming c. Using a WRITE statement ~
FORTRAN identifiers? d. Using an assignment statement
a. The last character must be a letter 44. Which of the following is a FORTRAN built in
b. FORTRAN identifiers are case sensitive function?
c. All Special characters are allowed. a. SQT(X)
d. Identifiers should consist of alphanumeric b. ARCTAN(X)
characters; with first being an alphabet ~ c. SQRT(X) ~
40. The following program segment; d. ARCSINE(X)
REAL:: Nile = 2.3, Niger = 6.0 45. The following program segment REAL:: K, X
INTEGER:: Senegal= 2, Congo = 3, Orange = 3.3, Y = 4.5, Z = 3.5
Orange = Nile *Senegal + Niger**Senegal K = SQRT (INT(X)*MAX(X, Y) +MIN(Y,
Write (*,*) Orange will write which of the Z))
following values? WRITE (K)
a. 40.6 Will write which of the following values?
b. 40.0 a. 8.23
c. 40 ~ b. 4.12 ~
d. 39 c. 3.34
41. The following program segment; d. 7.48
REAL:: Nile= 2.3, Niger= 6.0, Limpopo
Edited By: MR. ABDOUL

46. The following program segment REAL:: K, X Cocktail = g//j//h


= 7.6, Y = 6.4, Z = 2.8 WRITE (*,*) Cocktail, i
K = X + INT (Y) – INT (Z) END PROGRAM
WRITE (K) STRINGCONCARTINATION
Will write which of the following values? a. BananaAp,Sugar ~
a. 10.0 b. BanaApWa,Sugar
b. 11.6 ~ c. BanaAWatSugar
c. 11.0 d. BanaApWa,Sugarca
d. 10.4 50. What will be the input data for the program
47. Let * denotes a space. The following program segment below?
segment will produce CHARACTER (Len=8) :: Bayelsa
Which of the following options REAL :: Lagos, Adamawa
Character (Len=13):: Staircase= INTEGER :: Jigawa, Osun
“BetterNigeria” READ (*,*) Bayelsa, Lagos, Adamawa,
Staircase (1:7) = “prayfor” Jigawa, Osun
Write (*,*) Staircase a. Apple, 6.5, 500, 55, 3.4
a. prayforBetter b. Banana, 4.5, 70.0, 7, 10 ~
b. prayfor***** c. Apple, 6.5, 5.5, 55, 3.4
c. prayforBetterNigeria d. Grape, 66, 55, 7.0, 6
d. ****forBetter* 51. When more than two conditions needs to be
48. The following program segment will produce tested, which of the following constructs will
which of the following options be applicable?
Character (Len=12):: Staircase= a. IF CONSTRUCT
“BetterNigeria” b. IF-ELSE CONSTRUCT
Staircase (3:8) = 1234567 c. IF-ELSEIF CONSTRUCT ~
Write (*,*) Staircase d. DO CONSTRUCT
a. 1234567igeria 52. What will be printed by the following program?
b. 123terNigeria INTEGER N = 14, M = 10
c. pray1234567 IF (M.GE.N) THEN
d. Be123456geria ~ M =M+1
49. The output of the program below is: IF (N.EQ.M) THEN
PROGRAM STRINGCONCARTINATION N =N+5
IMPLICIT NONE ELSEIF (N.GT.0) THEN N = N + 10
CHARACTER (LEN=8), Parameter:: g = ENDIF
‘Banana’, h = ‘Water Melon’, cocktail M=M-1
CHARACTER (LEN=5), PARAMETER:: i = ENDIF
‘Sugarcane’, j = ‘Apple’ M=M-1
Edited By: MR. ABDOUL

WRITE (*,*) M, N a. A descriptor


END b. I descriptor
WRITE (*,*) M, N c. F descriptor
a. 11 20 d. X descriptor ~
b. 25 9 57. Real numbers can be formatted with
c. 10 14 ~ a. E descriptor
d. 20 11 b. ES descriptor
53. What will be the output of the following Nested c. F descriptor
Do loop statement? d. All of the above
DO 10 m=1,2 58. Which of the following is a correct READ
DO 11 J=1,6,2 WRITE(*,*) J format for the following data
11 CONTINUE **4000****400.00**HAKEEM Note that
10 ONTINUE END * denote space
a. 111222 a. Read (*, 2X, I4, 3X, F5.2, 2X, I2)
b. 135135 ~ b. Read (*, 2X, I4, 3X, F5.2, 2X, A) ~
c. 111315 c. Read (*, 2X, I4, 3X, A5, 2X, F5.2)
d. 113151 d. Read (*, 2X, I4, 3X, F3.2, 2X, A)
54. What will be printed by the following program 59. The IMPLICIT NONE statement is used
segment a. Before the keyword PROGRAM
INTEGER A (3), j b. To indicate termination of a program
A (1) = 1 c. To indicate that the first letter of a variable
DO 30 J = 2, 3 determine its type.
A (J) = 3 * A (J - 1) 30 CONTINUE d. To indicate that for each variable declared
WRITE (*,*) A the type must be specify. ~
END 60. The rank of a FORTRAN array is:
a. 1 2 6 a. The same as the shape of the array
b. 1 1 1 b. The index of the array
c. 1 2 3 c. The number of its permissible subscript ~
d. 1 3 9 ~ d. The elements of the array
55. How do you declare an integer array 61. The shape of an array is
Studentconsisting 3 columnsand 20 rows a. The same as the rank and the extent of each
a. INTEGER:: Student(20,3) dimension of that array ~
b. INTEGER:: Student(3,20) b. The index of the array
c. INTEGER::(20,3) c. The number of its permissible subscript
d. INTEGER::(3,20) d. The elements of the array
56. Which one of the following descriptors is used 62. Which of the following is true about
for leaving blank spaces FORTRAN array
Edited By: MR. ABDOUL

a. It can only be two dimensional


b. All values are stored in one cell
c. It can only two dimensional
d. It can be up to seven dimensional
Edited By: MR. ABDOUL

You might also like