C Programming - 2

Miscellaneous C Programming - 2

23 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which of the following is not a relational operator?

  1. <
  2. >
  3. =
  4. *
Question 2 Multiple Choice (Single Answer)

What happens if the variable A is equal to 30 when QBasic executes the following statement?
IF A = 32 THEN
A = A * 2
END IF

  1. The ELSE clause will be executed.
  2. Control will be passed to the statement following this one.
  3. The value of A will be doubled.
  4. An error will occur and program execution stop.
Question 3 Multiple Choice (Single Answer)

If X = 22, which of the following statements is executed?
If X <> 8 THEN
PRINT "Stop program"
END IF

  1. The statement Stop program will be displayed
  2. The THEN part of the statement will not be executed
  3. An error message will result
  4. The number 8 will be assigned to the variable X
Question 4 Multiple Choice (Single Answer)

If X = 7, what happens when the following statement is executed?
IF (X + 3) + 5 > 10 THEN
PRINT "Answer is correct."
END IF

  1. The first executable statement after this statement is executed.
  2.  Answer is correct. is printed.
  3. The program stops executing.
  4. An error message is displayed.
Question 5 Multiple Choice (Single Answer)

Directions: Use the following program segment:

IF Time < Best THEN
PRINT "NEW WORLD RECORD!"
ELSEIF Time < Best + 10 THEN
PRINT "GOOD RACE"
ELSE
PRINT "AVERAGE RACE"
END IF

If Time equals 120 and Best equals 121, what is output when this statement is executed?

  1. NEW WORLD RECORD!
  2. GOOD RACE
  3. AVERAGE RACE
  4. Nothing is output
Question 6 Multiple Choice (Single Answer)

Directions: Use the following program segment:

IF Time < Best THEN
PRINT "NEW WORLD RECORD!"
ELSEIF Time < Best + 10 THEN
PRINT "GOOD RACE"
ELSE
PRINT "AVERAGE RACE"
END IF

If Time equals 130 and Best equals 120, what is output when this statement is executed?

  1. NEW WORLD RECORD!
  2. GOOD RACE
  3. AVERAGE RACE
  4. Nothing is output
Question 7 Multiple Choice (Single Answer)

Directions: Use the following program segment:

        IF Sex$ = &quot;M&quot; THEN
           IF Height &gt; 66 THEN
              IF Weight &gt; 180 THEN
                 PRINT &quot;Try out for the football team.&quot;
              END IF
           END IF
        END IF

What happens if the value of Height is 66, Weight 181, and Sex equals  M when this statement is executed?

  1. The message Try out for football team. is displayed.
  2. Nothing happens; program execution simply continues on to the next statement.
  3. An error message is displayed.
  4. The program immediately stops executing.
Question 8 Multiple Choice (Single Answer)

Entering data interactively at the keyboard is called _______.

  1. inquiry-and-response mode
  2. programming mode
  3. indirect mode
  4. direct mode
Question 9 Multiple Choice (Single Answer)

Directions: Use the following expression.
(Height > 20) AND (Tree$ = "Hickory") OR NOT (Tree$ = "Oak")

Which of the logical operators in this expression will be evaluated first?

  1. AND
  2. NOT
  3. OR
  4. The order of evaluation makes no difference
Question 10 Multiple Choice (Single Answer)

The _______ statement allows the user to enter data during program execution.

  1. INPUT
  2. PRINT
  3. LOCATE
  4. REM
Question 11 Multiple Choice (Single Answer)

While using an INPUT statement, how many values can be entered at a time?

  1. Only one
  2. Two or less
  3. One or more
  4. INPUT statements do not accept values
Question 12 Multiple Choice (Single Answer)

A semicolon immediately after a prompt in an INPUT statement will cause _______.

  1. the prompt to print in the next available space
  2. a line to be skipped in the output
  3. a question mark to appear on the screen at the end of the statement
  4. an error to occur
Question 13 Multiple Choice (Single Answer)

When entering more than one value in response to a prompt, each value must be separated by _______.

  1. a semicolon
  2. a comma
  3. a colon
  4. using the spacebar
Question 14 Multiple Choice (Single Answer)

Directions: Use the following expression.
(Height > 20) AND (Tree$ = "Hickory") OR NOT (Tree$ = "Oak")

For which of the following values will the above expression evaluate as false?

  1. Tree$ = "PINE"; Height = 20
  2. Tree$ = "HICKORY"; Height = 21
  3. Tree$ = "OAK"; Height = 19
  4. Tree$ = "WALNUT"; Height = 21
Question 15 Multiple Choice (Single Answer)

Which statement is the best for entering data to programs, where the data changes often?

  1. PRINT
  2. LET
  3. INPUT
  4. PROMPT
Question 16 Multiple Choice (Single Answer)

Directions: Use the following program segment.

        SELECT CASE Choice
           CASE 10
              Price = Quantity * UnitPrice
           CASE 20
              Price = Quantity * UnitPrice * 0.95
           CASE 30
              Price = Quantity * UnitPrice * 0.90
           CASE ELSE
              PRINT &quot;Invalid Choice.&quot;
        END SELECT

What happens if Choice equals 20?

  1. Price equals Quantity - UnitPrice.
  2. Price equals 95% of Quantity - UnitPrice.
  3. Price equals 90% of Quantity - UnitPrice.
  4. Invalid Choice is displayed.
Question 17 Multiple Choice (Single Answer)

A _______ chart is used to determine how a program’s output will be formatted.

  1. structure
  2. flow
  3. spacing
  4. pseudocode
Question 18 Multiple Choice (Single Answer)

When the user enters the incorrect data in response to an INPUT statement, which of the following statements appears on the screen?

  1. Error numeric value expected
  2. Error character string expected
  3. Redo from last entry
  4. Redo from start
Question 19 Multiple Choice (Single Answer)

Directions: Use the following program segment:

        IF Sex$ = &quot;M&quot; THEN
           IF Height &gt; 66 THEN
              IF Weight &gt; 180 THEN
                 PRINT &quot;Try out for the football team.&quot;
              END IF
           END IF
        END IF

Which of the following could replace this statement?

  1. IF (Sex$ = "M") AND (Height > 66) AND (Weight >180) THEN PRINT "Try out for football team." END IF
  2. IF (Sex$ = "M") OR (Height > 66) OR (Weight > 180) THEN PRINT "Try out for football team." END IF
  3. IF (Sex$ = "M") AND (Height > 66) OR (Weight > 180) THEN PRINT "Try out for football team." END IF
  4. IF (Sex$ = "M") AND NOT (Height > 66) AND (Weight > 180) THEN PRINT "Try out for football team." END IF
Question 20 Multiple Choice (Single Answer)

By using a(n) _______, you can cause output to be placed in the next print zone.

  1. semicolon
  2. asterisk
  3. comma
  4. quotation mark
Question 21 Multiple Choice (Single Answer)

The _______ is used to separate multiple statements on a single physical line.

  1. colon
  2. asterisk
  3. pound (#)
  4. equal sign
Question 22 Multiple Choice (Single Answer)

Directions: Use the following program segment.

        SELECT CASE Choice
           CASE 10
              Price = Quantity * UnitPrice
           CASE 20
              Price = Quantity * UnitPrice * 0.95
           CASE 30
              Price = Quantity * UnitPrice * 0.90
           CASE ELSE
              PRINT &quot;Invalid Choice.&quot;
        END SELECT

Which of the following statements will cause the price to be 90% of Quantity - UnitPrice?

  1. CASE = 20 + 10
  2. Choice = 10 + 10
  3. Choice = 20 + 10
  4. Choice = 20
Question 23 Multiple Choice (Single Answer)

Directions: Use the following program segment.

        SELECT CASE Choice
           CASE 10
              Price = Quantity * UnitPrice
           CASE 20
              Price = Quantity * UnitPrice * 0.95
           CASE 30
              Price = Quantity * UnitPrice * 0.90
           CASE ELSE
              PRINT &quot;Invalid Choice.&quot;
        END SELECT

What happens if Choice equals 21?

  1. Price equals Quantity- UnitPrice.
  2. Price equals 95% of Quantity - UnitPrice.
  3. Price equals 90% of Quantity -UnitPrice.
  4. Invalid Choice is displayed.