WOLLO UNIVERSITY
KOMBOLCHA INSTITUTE OF TECHNOLOGY
Engineering -College--civil and water Eng. School -WRIE Department
Final Exam
For _1st year regular –2nd semester __Course Title -- introduction to computer science and programming
Course Code –COMP1051 Time allotted: 3 hrs.
Date: - ___________________
Name__________________________________________________ID.No__________sec_____
INSTRUCTIONS
Check the exam booklet contains 14 questions.
Read all the instructions carefully.
Attempt all question properly according to the instruction given.
Unreadable answer may not be marked.
You can use the back side of the paper if needed.
Using mobile phone is strictly forbidden.
Cheating is strictly forbidden.
Don't turn this page until you are told to do so !
FOR INSTRUCTOR’S USE ONLY
No Total (_______ %)
Mark
Score
GOOD LUCK!!
1
Part I: Fill in the blanks in each of the following :( 1pt each)
1. The object used to print information on the screen is_____________.
2. A C++ statement that makes a decision is ______________.
3. C++ stores lists of values in____________.
4. The elements of an array are related by the fact that they have the same_________ and____________.
5. An m-by-n array contains_____ rows, ____columns and _______elements.
Part II:
1. Consider a 2-by-3 integer array t.(1.5pt each)
a) Write a declaration for t?
b) How many rows does t have?
c) How many columns does t have?
d) How many elements does t have?
e) Write the names of all the elements in the second row of t?
f) Write the names of all the elements in the third column of t.
2. Write a single C++ statement or line that accomplishes each of the following:(1pt each)
a) Print the message "Enter two numbers".
b) Input three integer values from the keyboard that uses variables a, b and c.
c) Input a value into element 4 of single-subscripted floating-point array b
d) Initialize each of the 5 elements of single-subscripted integer array g to 8
3. Assume that long integer variables value1 and value2 have been declared and that value1 has been
initialized to 200000. For each of the following, write a single statement that performs the indicated
task.(1pt each)
a) Declare the variable lPtr to be a pointer to an object of type long.
b) Assign the address of variable value1 to pointer variable lPtr and display the address.
c) Print the value of the object pointed to by lPtr.
d) Assign the value of the object pointed to by lPtr to variable value2.
e) Print the value of value2.
4. Write a program that reads in the radius of a circle and prints the circle’s diameter, circumference and
area. Use the constant value 3.14159 for pi.(6pts)
5. Write a program that asks the user to enter two integers, and then prints the larger number followed by
the words "is larger." If the numbers are equal, print the message “These numbers are equal.”(6pts)
6. What does the following program print(out put)?(3pst)
#include <iostream>
using namespace std;
int main()
2
{
int y, x = 1, total = 0;
while ( x <= 10 ) {
y = x * x;
cout << y << endl;
total += y;
++x;
}
cout <<"Total is "<< total << endl;
return 0;
}
7. What is the output of the following program?(2pts)
#include<iostream>
using namespace std;
int main()
{
int age[5]={20,17,23,21,24};
cout<<age[0]<<endl;
cout<<age[3]<<endl;
cout<<age[4]<<endl;
cout<<age[1]<<endl;
cout<<age[2]<<endl;
return 0;
}
8. Identify and correct the error(s) in each of the following:( 5 pts)
a) if ( age >= 65 );
cout <<"Age is greater than or equal to 65"<< endl;
else
cout <<"Age is less than 65 << endl";
b) if ( age >= 65 )
cout <<"Age is greater than or equal to 65"<< endl;
else;
cout <<"Age is less than 65 << endl";
c) int x = 1, total;
while ( x <= 10 ) {
total += x;
++x;
}
d) While ( x <= 100 )
total += x;
3
++x;
e) while ( y > 0 ) {
cout << y << endl;
++y;
}
9. Write a do-while statement that reads three nonzero integers that determines and prints if they could be
the sides of a right triangle.(5pts)
Wollo University
Kombolcha Institute of Technology
4
Engineering-College-Civil and Water Eng.School-WRIE-Department
Name of teacher(s):_Hayat M. & Tegegn A. _course title: _ introduction to computer science and
programming
Course code: Comp 1051
1. _______________________________________
2. _______________________________________
5
Date______/_______/______Exam: mid final ̢
Exam Information:
Test Format No of Questions from each chapters
Chapter Chapter Chapter Chapter Chapter total
_3____ _4____ ___5__ _____ _____
True/false ______ _____ ______ ______ ______ ____
Fill the blank 2 3 - _____ _____ _____
Multiple choice
Work out
Essay 7 4
Total
Comments given by committee:
_________________________________________________________________________________________________________
_________________________________________________________________________________________________________
_________________________________________________________________________________________________________
_____________________________________________
Exam committee members sign
1. ___________________________________________________
2. ____________________________________________________
3. _______________________________________ _____________
Department Head:________________________ ____________ __________
Name Signature Date