0

C Programming - 2

Description: Miscellaneous C Programming - 2
Number of Questions: 23
Created by:
Tags: Miscellaneous C Programming - 2 Programming Fundamentals of Computer Programming Basic Fundamentals Hardware and Software
Attempted 0/23 Correct 0 Score 0

Which of the following is not a relational operator?

  1. <

  2. >

  3. =

  4. *


Correct Option: D

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.


Correct Option: B

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


Correct Option: A

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.


Correct Option: B

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


Correct Option: A

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


Correct Option: C

Directions: Use the following program segment:

IF Sex$ = "M" THEN IF Height > 66 THEN IF Weight > 180 THEN PRINT "Try out for the football team." 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.


Correct Option: B

Entering data interactively at the keyboard is called _______.

  1. inquiry-and-response mode

  2. programming mode

  3. indirect mode

  4. direct mode


Correct Option: A

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


Correct Option: B

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

  1. INPUT

  2. PRINT

  3. LOCATE

  4. REM


Correct Option: A

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


Correct Option: C

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


Correct Option: C

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


Correct Option: B

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


Correct Option: C

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

  1. PRINT

  2. LET

  3. INPUT

  4. PROMPT


Correct Option: C

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 "Invalid Choice." 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.


Correct Option: B

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

  1. structure

  2. flow

  3. spacing

  4. pseudocode


Correct Option: B

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


Correct Option: D

Directions: Use the following program segment:

IF Sex$ = "M" THEN IF Height > 66 THEN IF Weight > 180 THEN PRINT "Try out for the football team." 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


Correct Option: A

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


Correct Option: C

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

  1. colon

  2. asterisk

  3. pound (#)

  4. equal sign


Correct Option: A

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 "Invalid Choice." 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


Correct Option: C

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 "Invalid Choice." 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.


Correct Option: D
- Hide questions