Fundamentals of Programming C++ Test

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Fundamentals of Programming C++

I. MULTIPLE CHOICE. 15pts.


Directions: Read and understand the each given questions below. WRITE the correct letter of your answer on the given bluebook.

1. A program performs three basic operations: it gets data, it manipulates data and _______________.
a. It process the data c. It output the results
b. It outputs the data d. It process and output the data

2. The header file istream contains a variable declaration. In which of the following is the correct syntax?
a. cout c. cin>>
b. cin<<””; d. cin;

3. In which of the following is the correct variable declaration for header file ostream?
a. cout c. cin
b. cin d. cout<<””;

4. ostream is a data type that stands for ________________.


a. Overflow stream c. Output stream
b. Overhead stream d. Overheat stream

5. To use the cin and cout stream variable, every C++ program must use the preprocessor directive of which of the following?
a. #include iostream c. #include<Iostream>
b. #Include<”iostream”> d. #include<iostream>

6. Which of the following is the best syntax declaration of an input statement cin?
a. cin >> var1, c. cin >>”var:”
b. cin >> var1>>var2; d. cin >> var”

7. The input stream is used to store specific information to the specified variable inputted by the user using ______________.
a. cout c. #include<istream>
b. using namespace std; d. cin

8. Which extraction operator must be used in declaring an input stream syntax?


a. >> c. ::
b. << d. ;

9. Considering a variable declaration of a = 25, what is the correct syntax for an input stream syntax?
a. cin>>25 c. cin<<a
b. cin>>a d. cin>>a>>25

10. To use the cin and cout, the program must include the header file ______________.
a. Input stream c. iostream
b. Output stream d. using namespace std;

11. Which stream that best describes of storing data from a source to a computer?
a. Input stream c. #include<iostream>
b. Output stream d. iostream

12. In C++ programming language, basic program syntax must starts with the declaration of which following line of code?
a. #include<iostream> c. //comments
b. int main () d. using namespace std;

13. Which stream that best describes of storing data from a computer to a destination.
a. Output stream c. Variable stream
b. Input stream d. Data types

14. When the C++ program compiled and executed, the <<endl code will make return spaces by how many times?
a. 2 times c. 1 time
b. 3 times d. no return spaces will be created

15. IPC stands for ________________.


a. Input processor cycle c. Input processed cycle
b. Input processing cycle d. Input processing circuit

II. TRUE OR FALSE – LOGICAL OPERATION. 30pts.


Directions: Compute for the logical value of each operations below. Write TRUE or FALSE Value for AND, OR statements. For NOT
CONDITIONAL ? select the correct answer on the given choices.

A. LOGICAL AND B. LOGICAL OR C. LOGICAL NOT CONDITIONAL ?


III. Identification. Complete the table below. 20pts.

Data Type Description Size


char 1. 6.
int 2. 7.
bool 3. 8
float 4. 9.
double 5. 10.

IV. Write the syntax of the following. 25pts.


Selection Structure
1. If statement
2. Switch statement
Repetition Structure
1. While / Do while loop statement
2. For loop statement

V. Give the output of the given program segment below if the respective value entered for Fnum and Snum are the
following. 10pts.

1. OUTPUT
1. Fnum=5; Snum=10 ___________________________________
2. Fnum=10; Snum=5 ___________________________________
3. Fnum=25; Snum=10 ___________________________________
4. Fnum=2; Snum=2 ___________________________________
5. Fnum=10; Snum=25 ___________________________________
if (Fnum>Snum)
cout<<Fnum<<”is greater than” <<Snum;
if (Fnum<Snum)
cout<<Fnum<<”is less than” <<Snum;
if (Fnum==Snum)
cout<<Fnum<<”is equal to” <<Snum;

2. OUTPUT
1. Fnum=50; Snum=40 ___________________________________
2. Fnum=60; Snum=5 ___________________________________
3. Fnum=2000; Snum=1 ___________________________________
4. Fnum=2; Snum=200 ___________________________________
5. Fnum=0; Snum=-5 ___________________________________

if ((Fnum>=0) && (Fnum<100))


{
if ((Fnum<0) || (Fnum>100))
cout<<”NOTRE”;
else
cout<<”DAME”;
}
else
{
if ((Fnum>=0) && (Fnum<100))
cout<<”MIDSAYAP”;
else
cout<<”COLLEGE”;
}

You might also like