Fundamentals of Programming C++ Test
Fundamentals of Programming C++ Test
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<<””;
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
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
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 ___________________________________