Professional Documents
Culture Documents
Preliminary Examination
CS 111 (Programming 1)
C++ Programming Language
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
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.