You are on page 1of 3

Republic of the Philippines

University of Southeastern Philippines


College of Teacher Education and Technology
Tagum – Mabini Campus
Apokon, Tagum City

Preliminary Examination
CS 111 (Programming 1)
C++ Programming Language

GENERAL INSTRUCTION: Read the questions carefully. Kindly no erasure.

TEST I. MODIFIED TRUE OR FALSE. Write TRUE (capital letters) if you think the statement is true. Otherwise, if you think the
statement is wrong, change the underlined word to the word you think is the right answer.

________________________1. The system development procedure consists of three phases: program development and design,
documentation, and maintenance.
________________________2. The main()function identifies the body point of a C++ program.
________________________3. C++ statements must be terminated by a colon.
________________________4. Computer - language instructions consist of two parts: an instruction and an address.
________________________5. The cout object can be used to display all C++ data types.
________________________6. Variables of different type can be declared with a single declaration statement.
________________________7. Assignment operator can be used more than once in the same expression.
________________________8. The programs used to operate a computer are also referred to as software.
________________________9. Declaration statements inform the processor of a function’s valid variable names.
________________________10. A computer system is a self-contained unit of instructions and data used to operate a computer to
produce a specific result.
________________________11. Functions can be included in larger expressions.
________________________12. The increment operator can be used as prefixes or postfixes. In a postfix operation, the variable is
incremented before its value is used.
________________________13. Relational expressions, also called conditions, are used to assign operands.
________________________14. More complex conditions can be constructed from relational expressions by using C++’s relational
operators, && (AND), || (OR), and ! (NOT).
________________________15. The <iomanip> library provides functions for calculating square root, logarithmic, and other
mathematical computations.
_______________________ 16. An equation in a C++ program is a sequence of one or more operands separated by operators.
________________________17. An algorithm is a step-by-step procedure that must terminate; it describes how a computation or task
is to be performed.
________________________18. When a getch() statement is encountered, the computer temporarily suspends further execution until
enough data has been entered for the number of variables in this statement.
________________________19. An if-else statement is used to select between two alternative statements based on an expression’s
value.
________________________20. A block statement is a sequence of single statements between braces.
________________________21. In a posttest or entrance-controlled loops, the tested condition is evaluated at the beginning of the loop,
which requires setting the tested condition explicitly before loop entry.
________________________22. The expression in parentheses of a loop is the condition that’s tested to determine whether the
statement following the parentheses is executed.
________________________23. The do statement is used to create posttest loops because it checks its expression at the end of the
loop.
________________________24. In a nested loop, the first loop, controlled by the value of a certain variable/constant is called the outer
loop.
________________________25. In a variable-count loop, the condition is used to keep track of how many repetitions have occurred.

TEST II. MULTIPLE CHOICE. Choose the letter of the correct answer.

26. What do you call when the ++ operator appears before a variable?
a. Prefix increment operation c. Postfix increment operation
b. Prefix decrement operation d. Postfix decrement operation
27. It set the floating-point precision to n places.
a. setw(n) b. setprecision(n) c. setfill(‘x’) d. setiosflags(flags)
28. It refers to an item, such as a variable or argument, which sets a condition usually considered active or nonactive.
a. Input b. output c. flags d. manipulator
29. It always show the decimal point with six digits after the decimal point.
a. ios::fixed b. ios::showpoint c. ios::showops d. ios::scientific

30. Which of the following is a two-way selection statement?


a. If statement c. if-else if-else statement
b. if-else statement d. switch statement
31. The tested condition doesn’t depend on a count being reached, but on a variable that can change interactively with each pass
through the loop. What do you call this kind of loop?
a. Variable-condition loop c. while loop
b. Fixed-count loop d. do-while loop
32. It is controlled by a repetition statement that tests a condition to determine whether the code will be executed.
a. Selection statements c. Loops
b. Conditional expressions d. Assignment expressions
33. The following are entrance-controlled loops, except:
a. do-while b. while c. for d. do
34. In this type of looping, In a while statement, the statement following the expression is executed repeatedly as long as the
expression retains a non-zero value, instead of just once, as in an if-else statement.
a. for b. while c. do while d. do
35. This statement must contain at least one statement that alters the tested expression’s value.
a. for b. while c. do while d. do

TEST III. FLOWCHARTING. Make a flowchart of the following and display the output of the program. (10 points each item)

1) 2)
#include<iostream> #include<iostream>
#include<conio.h> #include<conio.h>
#include<cmath> #include<cmath>
using namespace std; using namespace std;
int main(){ int main(){
int n=5,i,s=1,p=0,j=1; int i,j,k=3,x=7;
for(i=1;i<=n;i++){ for(i=0;i<=100;i++,x--){
if(i!=1)cout<<"+"; if(i<7){
s=pow(i,j); j=pow(k,x);
p=p+s; cout<<j<<" ";
cout<<s; }else{
j++; break;
} }
cout<<"="<<p<<endl; }
getch(); getch();
return 0; return 0;
} }

TEST IV. DEBUGGING. Debug the following codes the best you can.

1 #include <iostream> 29 cout endl;


2 #include <conio> 30 horizPos = 0;
3 using namespace std; 31 beginHoriz = beginHoriz - 1;
4 int main () { 32 endHoriz = endHoriz + 1;
5 char width, horizPos, vertPos, 33
6 beginHoriz, endHoriz; 34 horizPos = 0;
7 int c; 35 beginHoriz = 1;
8 cout << "Enter a character: "; 36 endHoriz = width - 2;
9 cin << c; 37 while (beginHoriz <= width/2)
10 cout << "Enter an integer: "; 38 {
11 cin >> with; 39 whle (horizPos < width) {
12 if (width % 2 == 0) width = 40 if (horizPos < beginHoriz)
13 width+1; 41 cout >> " ";
14 horizpos = 0; 42 else if (horizPos <=
15 beginHoriz = width / 2; 43 endHoriz) cout << c;
16 endHoriz = beginHoriz; 44 else cout << " "
17 while (beginHoriz <= 0) { 45 horizPos = horizPos + 1;
18 while (horizPos < width) { 46 }
19 if (horizPos < beginHoriz) 47 cout << endl;
20 cout << " "; 48 horizPos = 0;
21 else if (horizPos <= 49 beginHoriz = beginHoriz + 1;
22 endHoriz) cout << c; 50 endHoriz = endHoriz - 1;
23 else cout << " "; 51 }
24 horizPos = horizPos + 1; 52 getch;
25 } 53 return0;
26 54 }
27 55
28 56
2 conio - conio.h
5 char - int
7 int - char
9 cin<<c - cin>>c;
11 with - width
12 width % 2 - (width % 2 )
14 horizpos - horizPos
17 <= - >=
29 cout endl; - cout << endl;
33 } or 32 endHoriz = endHoriz + 1;}
39 whle - while
41 cout >> " "; - cout << " ";
44 else cout << " " - else cout << " ";
52 getch; - getch();
53 return0; - return 0;

50 endHoriz = endHoriz -1;

You might also like