Question: What is the proper way to declare a student’s grade point average throughout the term if this item is needed in several places in a program?

Answer Options:
A) variable int gpa
B) variable float gpa
C) constant int gpa
D) constant float gpa

Answer: B) variable float gpa

Question: A program calculates the average miles per gallon given miles traveled and gas consumed. How should the item that holds the miles per gallon be declared?

Answer Options:
A) Constant float milesPerGallon
B) Variable float milesTraveled
C) Variable float milesPerGallon
D) Constant float milesTraveled

Answer: C) Variable float milesPerGallon

Question: It is given that integer x = 41 and integer y = 16. What is the value of the expression (x % 8) – у?

Answer Options:
A) 15
B) 11
C) 8
D) 1

Answer: A) -15

Question: Given integer x = 12 and integer y = 4. What is the value of the expression x + y / 2?

Answer Options:
A) 06
B) 08
C) 14

Answer: C) (corresponding to 14). 14

Question: Which two types of operators are found in the code snippet not (g != 8) ?

Answer Options:
A) Equality and logical
B) Assignment and arithmetic
C) Logical and arithmetic
D) Equality and arithmetic

Answer: A) Equality and logical

Question: What are two examples of equality operators?

Answer Options:
A) not
B) !=
C) /
D) ==
E) <=

Answer: B) !=; D) ==

Question: Which expression evaluates to 14 if integer y = 13?

Answer Options:
A) 11 + y % 5
B) 11.0 – y / 5
C) 11 – y / 5.0
D) (11 + y) % 5

Answer: A) 11 + y % 5

Question: Which expression has a value equal to the rightmost digit of the integer q = 16222?

Answer Options:
A) 10 % q
B) q % 10
C) q % 10000
D) q / 100000

Answer: B) q % 10

Question: Which data type should be used to hold the value of a person’s body temperature in Fahrenheit?

Answer Options:
A) Integer
B) String
C) Boolean
D) Float

Answer: D) Float

Question: What is a string?

Answer Options:
A) very precise sequence of steps
A) sequence of characters
A) name that refers to a value
A) built-in method

Answer: B) A sequence of characters

Question: A function should determine the average of x and y. What should be the function’s parameters and return value(s)?

Answer Options:
A) Parameters: x, y Return value: average
B) Parameters: none Return values: x, y
C) Parameters: average Return values: x, y
D) Parameters: x, y, average Return value: none

Answer: A) Parameters: x, y Return value: average

Question: A function should convert a Fahrenheit temperature (F) to a Celsius temperature (C). What should be the output from the function?

Answer Options:
F) and 32
F) only
C) only
F) and C

Answer: C) C only

Question: A function should return 0 if a number, N, is even and 1 if N is odd. What should be the input to the function?

Answer Options:
A) 1
B) N
C) Even
D) 0

Answer: B) N

Question: Function Greeting () Put “Hello!” to output What is put to output by calling Greeting) twice?

Answer Options:
A) Hello!
B) Hello!Hello!
C) Hello!!

Answer: Hello! Hello!

Question: Consider the given function. function E(string s1, string 2) Put s1 to output Put ” and ” to output Put s2 to output What is the total output when F (sign, horse) is called 2 times?

Answer Options:
A) sign and horse
B) sign and horse
C) sign and horse and sign and horse
D) sign and horsesign and horse
E) sign and horse sign and horse

Answer: C) sign and horsesign and horse

Question: What are two examples of valid function calls?

Answer Options:
A) PrintSample ()
B) GetHeight (integer 3, integer 4)
C) CountFactors (96 integer)
D) function Sample (float 2.0)
E) convert_value (12) returns eVal
F) round_number (4.723, 2)

Answer: A) PrintSample (); F) round_number (4.723, 2)

Question: What does a function definition consist of?

Answer Options:
A) list of all other functions that call the function
B) The function’s argument values
C) An invocation of a function’s name
D) The function’s name, inputs, outputs, and statements

Answer: D) The function’s name, inputs, outputs, and statements

Question: What is required for all function calls?

Answer Options:
A) Input arguments
B) Parameters
C) Function name
D) Output values

Answer: C) Function name