0% found this document useful (0 votes)
811 views5 pages

Final Exam (C++) - 1

This document is a final exam for a Fundamentals of Programming I course. It consists of 5 parts worth a total of 40 points: 1. True/false and multiple choice questions worth 15 points 2. Short answer questions worth 19 points 3. Programming problems worth 9 points 4. A bonus programming problem worth 5 points 5. Instructions state the exam is closed book and cheating is not allowed.

Uploaded by

waryaa kalay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
811 views5 pages

Final Exam (C++) - 1

This document is a final exam for a Fundamentals of Programming I course. It consists of 5 parts worth a total of 40 points: 1. True/false and multiple choice questions worth 15 points 2. Short answer questions worth 19 points 3. Programming problems worth 9 points 4. A bonus programming problem worth 5 points 5. Instructions state the exam is closed book and cheating is not allowed.

Uploaded by

waryaa kalay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Jigjiga University

College of Engineering and Technology

Department of Computer Science

Fundamental of Programming I

Final Examination

Max Points: 40%


Time Allowed: 2 hrs.
Instructor: Ayenew Yifru

ID.No:______________________________

Instructions:

Write your Id number in the cover page (don’t write your name in any part of the
exam paper).
Write your answers clearly and neatly.
Any try of cheating and copy from short notes is strictly forbidden and the
invigilator made a serious measures.
Check your exam paper has five parts and four pages excluding the cover page.

Instructor Use only

Part I (5%) Part II (10%) Part III (19%) Part IV (6%) Bonus (5%) Total (40%)
Part I. Write true if the statement is correct and write false if the statement is
incorrect. (1 pt. each)

1. If/else and switch statements are a C++ programming statements that are used to doing
tasks repeatedly.
2. The syntax and function of while and do…while loops are the same.
3. Algorithm is as a step-by-step sequence of instructions that must terminate and describe
how the data is to be processed to produce the desired outputs.
4. Any pseudocode is dependent on a specific programming language (like C++ or Java).
5. A pseudocode is a schematic representation of an algorithm or a process.

Part II. Multiple choice questions (1.5 pts. Each)


Consider the following sample code to answer question number 1 and 2.
int sum=0, prod=1;
for (int i=1; i<=5; i++)
{
sum +=i;
prod +=i;
i++;
}
1. What is the new value of a variable sum?
a. 15 c. 9
b. 12 d. 8
2. What is the new value of a variable prod?
a. 120 c. 30
b. 15 d. 45
3. One of the following is not true about for loop.
a. Variable initialization is done in each iteration.
b. Increment (decrement) operation is done only once.
c. The loop run at least once in any condition.
d. None of the above.

Final Exam Page 1


4. One of the following is a correct order of steps in software development life cycle?
a. Feasibility analysis, requirement analysis, design, implementation and testing
b. Requirement analysis, feasibility analysis, design, implementation and testing
c. Design, feasibility analysis, requirement analysis, implementation and testing
d. Testing, feasibility analysis, requirement analysis, design and implementation
5. A rhombus in flowchart diagram represents_______________________.
a. Process c. Input/ Output
b. Decision block d. Terminal
Consider the following sample code to answer question number 6 and 7.
int x;
switch (x)
{
case 3:
cout<<”x=”<<x*x;
case 4:
cout<<”x=”<<x+x;
break;
default:
cout<<”x=”<<5*x;
}
6. What is the output when the value of x=3?
a. 6 c. 18
b. 9 d. 12
7. What is the output when the value of x=7?
a. 35 c. 14
b. 49 d. 98

Part III. Short answer questions

1. What is the main difference between while and do…while loops? (2 pts.)
2. What is infinite loop? How it happens in programs? Give one example? (3 pts.)

Final Exam Page 2


3. Write a pseudocode for accepting two number and checks whether the numbers are positive
or negative and display the larger one. And draw a flow chart for it. (4 pts.)
4. Debug the error in the following sample codes and rewrite the codes correctly. (2 pts. each)
a. if ( age >= 65 )
cout << "Age is greater than or equal to 65" << endl;
else;
cout << "Age is less than 65 << endl";
b. int x = 1, total;
do
{
total += x;
x++;
}
5. What is the output of the following sample C++ programs? (2 pts. Each)
a. int x=9, y=11;
if ( x < 10 )
{
if ( y > 10 )
cout << "*****" << endl;
}
else
{
cout << "#####" << endl;
cout << "$$$$$" << endl;
}

b. int x=10;
while (x<10)
{
x=x*x;
x++;
}
cout<<”x=”<<x;

Final Exam Page 3


c. int x=10;
do
{
x=x*x;
x++;
}
cout<<”x=”<<x;

Part IV. Programming

1. Write a C++ program for short answer question number 3. (3 pts.)


2. Write a program that reads three nonzero double values and determines and prints whether
they could represent the sides of a triangle (hint a+b>c and b+c>a and a+c>b). (3 pts.)

Part V. Bonus (5 pts.)

1. Write a program that reads in two integers and determines and prints if the first is a multiple
of the second.

Final Exam Page 4

You might also like