Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

University of Technology

Electromechanical Engineering Dept.


Energy and Renewable Energies Engineering Branch
Final Exam, 2019-2020
Class: 2nd Year Time: 3 hours
Subject: Advanced Programming C++ Date: 5/ 8 / 2020
Examiner: Dr. Akeel A. Abtan

Group A: Answer two questions of (Q1, Q2 or Q3)


Q1: Write a program to print the result of student as follows: (15 Degree)
NON if X>100.
Pass if X≥50.
Fail if X<50.

Q2: Write a program to sort the array [A] in ascending order and print its
elements after sorting. (15 Degree)
[A]={4, 7, 2, 12, 14, 5, 9, 11, 3, 8}

Q3: Write a program to find the value of Z by using function called FunctionZ
and function called FunctionS3 (15 Degree)

√𝑺𝟑+𝒆𝟐𝒙
𝒁= where 𝐒𝟑 = 𝐬𝐢𝐧(𝐱 𝟑 )
𝑺𝟑

Group B: Answer one question (Q4 or Q5)

Q4: Answer by true or false: (12 Degree)

1- Switch statement is not a selection statement.


2- Function setw(x) generates (x) spaces between outputs.
3- \ n can be used as an alternative to endl.
4- Int is used for declaring the real numbers.
5- The index of array starts from one in C++ language.
6- Functions cannot return more than one value at a time.
7- Using the function sin(x) does not need to include any header file.
8- a+=2 means new value of a = old value of a + 2.
9- Each C++ program may have many main functions.
10- The cout<< output statement is used to print text on the screen.
11- If a function returns no value, the return type must be declared as void.
12- The break command is used to exit a loop.

Q5: Choose the correct answer: (12 Degree)

1. Which from the following is not a maths functions?


a. exp( ) b. time ( ) c. log ( ) d. pow ( )

2. How many choices are possible when using a single if-else statement?
a. 1 b. 2 c. 3 d. 4

3. What will be the values of x, m and n after execution of the following


statements?
Int x, m, n;
m=10;
n=15;
x= ++m + n++;
a. x=25, m=10, n=15
b. x=27, m=10, n=15
c. x=26, m=11, n=16
d. x=27, m=11, n=16

4. The size of char variable is


a. 1 byte b. 2 byte c. 3 byte d. 4 byte
5. Which of the following is not a standard data type?
a.int b.char c.float d.date

6. Which of the following is not a comparison operator in C++ language?


a. > b. <= c. = d. = =

7. The maths function acos(x) stands for


a. Inverse cos(x) b. Inverse sin(x) c. Inverse Tan(x) d. csc(x)

8. The objects of an array is called as


a. Elements of an array b. Function of an array
c. Indexes of an array d. all of them

9. The break statement is used in


a. For loop b. While loop c. Switch Statement d. None of them

10. The do While statement is almost same as


a. For loop b. if else c. While loop d. Switch Statement

11. Which function must be used to generate random numbers:


a. cos( ) b. Rand( ) c. strlen( ) d.setw( )

12. To transfer execution to the next iteration of the loop, we select:


a. break b. continue c. goto d. endl

Good Luck

You might also like