Anda di halaman 1dari 3

NORALA NATIONAL HIGH SCHOOL

Norala, South Cotabato


Fourth Midterm Examination
ICT – Monaco
February 23 & 24, 2017
Name:____________________________________________________________________________ Score:___________

I. Multiple Choices: Read each statement carefully and select the correct answer from the given choices below. Write
the letter only on the space provided before the number.
____1. End-of-line comments that should be ignored by the compiler are denoted using:
A. Two forward slashes ( // ). B. Three forward slashes ( /// ).
C. A slash and a star ( /* ). D. A slash and two stars ( /** ).
____2. Which of the following is NOT one of the C++ control structures?
A. if B. switch C. break D. do…while
____3. Which of the following is a double-selection statement?
A. if B. if…else. C. do…while. D. switch.
____4. The escape sequence for a newline is:
A. \n B. \t C. \r D. \a
____5. Which of the following is a repetition structure?
A. if. B. if…else. C. do…while. D. switch.
____6. Which of the following is NOT a valid C++ identifier?
A. my Value B. _AAA1 C. width D. m_x
____7. If grade has the value of 60, what will the following code display?
if ( grade >= 60 )
cout << "Passed";
A. nothing B. 60 C. Passed D. cout << "Passed";
____8. Which of the following is the escape character?
A. * B. \ C. \n D. “
____9. Which of the following does NOT display correctly if answer is equal to 7 and incorrect if answer is NOT equal to
7?
A. if ( answer == 7 ) B. cout << answer == 7 ? "correct" : "incorrect";
cout << "correct";
else
cout << "incorrect";
C. cout << ( answer == 7 ? "correct" : "incorrect" ); D. answer == 7 ? cout << "correct" : cout << "incorrect";
____10. Which of the following is a variable declaration statement?
A. int total; B. #include <iostream> C. int main() D. // first string entered by user
____11. Which of the following statements does NOT overwrite a preexisting value stored in a memory location?
A. int a; B. number = 12; C. y = y + 2; D. width = length;
____12. Which of the following is not an arithmetic operator?
A. + B. - C. = D. %
____13. Each of the following is a relational or equality operator EXCEPT:
A. <= B. =! C. == D. >
____14. How many times will the following loop print hello?
i = 1;
while ( i <= 10 )
cout << "hello";
A. 0. B. 9. C. 10. D. An infinite number of times.
____15. What is WRONG with the following while loop?
while ( sum <= 1000 )
sum = sum – 30;
A. The parentheses should be braces.
B. Braces are required around sum = sum – 30;.
C. There should be a semicolon after while ( sum <= 1000 ).
D. sum = sum – 30 should be sum = sum + 30 or else the loop may never end.
___16. Allow conditional processing which extends the usefulness of program by the use of simple logic or test to
determine which blocks of code are executed.
A. Structure control B. Selection C. Sequence D. Repetition
____17. Which of the following for headers is NOT valid?
a. for ( int i = 0; i < 10; i++ )
b. int i = 0;
for ( ; i < 10; i++ )
c. for ( int i = 0; int j = 5; ; i++ )
d. All of the above.
____18. What will the following program segment do?
int counter = 1;
do
{
cout << counter << " ";
} while ( ++counter <= 10 );

A. Print the numbers 1 through 11. B. Print the numbers 1 through 10.
C. Print the numbers 1 through 9. D. Cause a syntax error.
___19. Which of the following does counter-controlled repetition require?
A. An initial value.
B. A condition that tests for the final value.
C. An increment or decrement by which the control variable is modified each time through the loop.
D. All of the above.
___20. Enable combining individual instruction into a single logical unit with one entry and one exit point.
A. Structure control B. Sequence C. Selection D. repetition
___21. A switch statement should be used.
A. As a single-selection structure.
B. As a double-selection structure.
C. As a multiple-selection structure.
D. To replace all if…else statements.
___22. Is used to conditionally execute a block of code based on whether a test condition is true.
A. Selection B. Sequence C. If Statement D. Repetition
___23. In a switch statement.
A. A break is required after each case.
B. Multiple actions in a case do not need to be enclosed in braces.
C. A default case is required.
D. A break is required after the default case.
___24. Repetitively execute a block of code until a Boolean condition changes state.
A. If statement B. Sequence C. Loop D. Selection
___25. Which of the following is correct when labeling cases in a switch structure?
A. case1 B. Case1 C. case 1 D. Case 1
II. TRUE OR FALSE. Write the word TRUE if the statement is correct else write FALSE if it is wrong. Write your answer on
the space provided before the number.
______1. The while loop is used to execute a block of code as long as some condition is true.
______2. Do-while loop also executes a block of code as along as a condition is satisfied.
______3. The switch statement is a construct that is used to replace deeply nested or chained if/else statements.
______4. The else statement provides a way to execute one block of code if a condition is true, another if it is false.
______5. Nested if-else statement may be nested and may express very complex logic.
______6. Control structure the flow of execution in a program or subprogram (function).
______7. Selection structure allow conditional processing which extends the usefulness of programs by the use of
simple logic or test to determine which blocks of code are executed.
______8. The if-statement is used to conditionally execute a block of code bases on whether a test condition is true.
______9. Sequential statements are grouped by means of using brace {,}.
______10. Switch statement when an expression is found that is equal to the tested variable, execution continues until a
break statement is encountered.
III. Application. Describe the output of the following C++ program. (5 pts)
#include <oistream>
Using namespace std;
int A, B, C;
main(){
A= 1, B = A + 2, C = B – 3
cout << A << B << C,<<endl;
}
Table of Specification

60% 30% 10%


Topics TOTAL
Easy Average Difficult
Comments 1
Control Structures 2
Selection structures 1
If Statements 3
If-else statements
Do..while Statements
While Statements
Program 5

Anda mungkin juga menyukai