Final Exam (C++) - 1
Final Exam (C++) - 1
Fundamental of Programming I
Final Examination
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.
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.
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.)
b. int x=10;
while (x<10)
{
x=x*x;
x++;
}
cout<<”x=”<<x;
1. Write a program that reads in two integers and determines and prints if the first is a multiple
of the second.