C-Plus-Plus QuestionsBy Kritika Papne / March 21, 2023 0 votes, 0 avg 225 123456789101112131415 C-Plus-Plus Questions 1 / 15 1. What will be the output of the following C++ code? #include using namespace std; int main() { int a, b; int* c; c = &a; a = 200; b = 200; *c = 100; b = *c; cout << *c << " " << b; return 0; } A. 100 200 B. 100 0 C. 200 200 D. 100 100 2 / 15 2. Identify the correct syntax for declaring arrays in C++. A. array arr[10] B. array{10} C. int arr[10] D. int arr 3 / 15 3. Which of the following is correct about friend functions? A. Friend functions use the dot operator to access members of a class using class objects B. Friend functions can be private or public C. Friend cannot access the members of the class directly D. All of the mentioned 4 / 15 4. What will be the output of the following C++ code? #include using namespace std; void Sum(int a, int b, int & c) { a = b + c; b = a + c; c = a + b; } int main() { int x = 2, y =3; Sum(x, y, y); cout << x << " " << y; return 0; } A. 2 3 B. 6 9 C. 2 15 D. compile time error 5 / 15 5. What will be the output of the following C++ program? #include using namespace std; int main() { int a = 5; auto check = [=]() { a = 10; }; check(); cout<<"Value of a: "< A. error B. Segmentation fault C. Value of a: 5 D. Value of a: 10 6 / 15 6. What will be the output of the following C++ code? #include using namespace std; class number { int i; public: int geti(); void puti(int j); }; int number::geti() { return i; } void number::puti(int j) { i = j; } int main() { number s; s.puti(10); cout << s.geti( ); return 0; } A. 10 B. 11 C. 20 D. 22 7 / 15 7. Which is more effective while calling the C++ functions? A. call by object B. call by pointer C. call by value D. call by reference 8 / 15 8. What will be the output of the following C++ code snippet? #include #include using namespace std; int main () { int array[] = {0, 2, 4, 6, 7, 5, 3}; int n, result = 0; for (n = 0; n < 8; n++) { result += array[n]; } cout << result; return 0; } A. 21 B. 27 C. 26 D. 25 9 / 15 9. Pick the incorrect statement about inline functions in C++? A. Saves overhead of a return call from a function B. They are generally very large and complicated function C. These functions are inserted/substituted at the point of call D. They reduce function call overheads 10 / 15 10. what will be the output of the following C++ code snippet? int main() { int i=0,x=0; for(i=1;i<10;i*=2) { x++; cout< A. 1234567899 B. 12345678910 C. 123455 D. 12344 11 / 15 11. What is the output of this C++ program in the “test.txt” file? #include using namespace std; int main () { long pos; ofstream outfile; outfile.open ("test.txt"); outfile.write ("This is an apple",16); pos = outfile.tellp(); outfile.seekp (pos - 7); outfile.write (" sam", 4); outfile.close(); return 0; } A. This is an apple B. apple C. sample D. This is a sample 12 / 15 12. What did we call an array of the one-dimensional array? A. Single Dimensional array B. Multi-Dimensional array C. 2D Array (or 2-Dimensional array) D. Both A and B 13 / 15 13. what will be the output of the following C++ code snippet? #include void Execute(int &x, int y = 200) { int TEMP = x + y; x+= TEMP; if(y!=200) cout< A. 5020–5020-- B. 5020–7012020--12020-- C. 5020–70120200--5020 D. 5020–7050200--5020-- 14 / 15 14. Which of the following is correct about this pointer in C++? A. this pointer is passed as a hidden argument in all static variables of a class B. this pointer is passed as a hidden argument in all the functions of a class C. this pointer is passed as a hidden argument in all non-static functions of a class D. this pointer is passed as a hidden argument in all static functions of a class 15 / 15 15. What will be the output of the following C++ code? #include using namespace std; int gcd (int a, int b) { int temp; while (b != 0) { temp = a % b; a = b; b = temp; } return(a); } int main () { int x = 15, y = 25; cout << gcd(x, y); return(0); } A. 15 B. 25 C. 375 D. 5 Your score isThe average score is 32% LinkedIn Facebook VKontakte 0% Restart quiz By WordPress Quiz plugin Written by Shubhranshu Shekhar, who has trained 20000+ students in coding. Kritika Papne