113x Filetype PDF File size 0.60 MB Source: nashamabau.weebly.com
C++ Final Exam 2017/2018 1) All of the following are examples of integral data types EXCEPT ______. o A Double o B Char o C Short o D Int 2) After the execution of the following code, what will be the value of numb if the input value is 5? 1. cin >> numb; 2. if (numb > 0) 3. numb = numb + 10; 4. else 5. if (numb > 5) 6. numb = numb + 15; o A 0 o B 5 o C 25 o D 15 3) What type of C++ statement(s) stores a value in a variable? o A both input and assignments o B assignments o C output o D input 4) Which of the following is NOT a reserved word in C++? o A return B int C const D num 5) What is the output? 1. int n = 0; 2. cout << ((n) ? n++ : ++n); o A 0 o B 1 o C None of these o D 2 Page 1 of 18 #NASHAMA_BAU @NashamaBAU C++ Final Exam 2017/2018 6) What is the output? 1. int x = 5; 2. cout<< (x++)+x<8) 2. { 3. cout << " ** " << endl ; 4. cout << "****" << endl; 5. } 6. else if (9 == 4) 7. cout << "***" << endl; 8. else 9. cout << "*" << endl; o A **** o B *** o C * o D ** 8) Which of these is a valid reserved word in C++? o A Char B Include C Double D Const o E None of these 9) Suppose that x, y, z, and w are int variables. The expression x(y+z)/w in C++ is written as o A x * (y + z) / w o B x * y + z / w o C x * y + x * z / w o D x (y + z) / w 10) The expression static_cast (6.9) + static_cast (7.9) evaluates to ____. o A 14 o B 14.8 o C 13 o D 15 Page 2 of 18 #NASHAMA_BAU @NashamaBAU C++ Final Exam 2017/2018 11) Suppose that ch1, ch2, and ch3 are variables of the type char and the input is: A B C **What is the value of ch3 after the following statements execute? 1. cin.get(ch1); 2. cin.get(ch2); o cin.get(ch3); o A 'B' o B 'C' o C 'A' o D '\n' 12) Suppose x and y are int variables. Consider the following statements: 1. if (x > 5) 2. y = 1; 3. else if (x < 5) 4. { 5. if (x < 3) 6. y = 2; 7. else 8. y = 3; 9. } 10. else 11. y = 4; **What is the value of y if x = 3? o A 3 o B 1 o C 2 o D 4 Page 3 of 18 #NASHAMA_BAU @NashamaBAU C++ Final Exam 2017/2018 13) The value of the expression 26 – 14 % 3 + 1 is ____. o A 1 o B 25 o C 24 o D 0 14) Suppose that x is an int variable, ch is a char variable, and the input is: 276. **Choose the values after the following statement executes: cin >> ch >> x; o A ch = '2', x = 76 o B ch = '2', x = 276 o C ch = ' ', x = 276 o D Input Failure 1. char ch1, ch2; 2. cin >> ch1; 3. cin.get(ch2); 4. cout << ch1 << ch2; 15) If the input is: M N **what is the output? o A MN B M C M N D None of these E N 16) What is the output of the following C++ code? 1. x = 6; 2. if (x > 10) 3. cout << "One "; 4. cout << "Two "; o A One o B Two o C One Two o D Two One Page 4 of 18 #NASHAMA_BAU @NashamaBAU
no reviews yet
Please Login to review.