Majmaah University College of Science in Zolfi Dept. of Computer Science & Info. Name : (برنامج تجسير) البرمجة الشيئية Midterm Exam on C++ OOP Time: 2 Hr 23-6-1435 ID: Answer the followings 1- What is the correct variable type for storing the following data? Provide meaningful variable names for the variables into the following table? 1234- Description The number of books in a bookshelf The cost of this book The number of people in the world The word Hello Variable name ` 2- What is the output of the following program? #include <iostream> using namespace std; Outputs: int main( void ) { int x = 25; string str2 = “This is a test\n”; cout << ”Test” << 1 << 2 << ”3”; cout << 25 %7 << “\n” << str2; return 0; } 3- Write a program that asks users for their names, that greets them, and that asks them for two numbers and then provides the sum. 4- Write a program to calculate the area and circumference of a circle with radius R where : Circumference= 2 R and Area = R2 , = 3.141592 1 Type 5- What happens when you store 10.3 as an integer? What about 0.6? Can you store –101.8 as an integer? 6- Complete the following by operators ( = , > , < , ! , == and &) Max x y ? y : x ; Min x y ? y : x ; 7- Let int x = 5; int y = 6; int z = y++; z = ++x + y; Output: cout<< "x="<< x; cout<< "y="<< y; cout<< "z="<< z; 8- Write a program to calculate the sum {1 + 2 + 3 + . . . + N} 9- Write a conditional statement that assigns x * y if x is even; otherwise, if x is odd and y doesn’t equal 0, assign x to x / y; if neither of the preceding cases is true, output to the screen that y is equal to 0. 10- Write a program to display a multiplication table from 1 to 10, which requires two nested for loops. 2