Result for: Sandesh Dasharath Ganpatil
Exam Name: C++
Download Result (PDF)Email: [email protected]
Total Marks: 45.0
Score: 39.0
Percentage: 86.67%
Question Answers
| Sr. No. | Question | Selected Answer | Correct Answer |
|---|---|---|---|
| 1 | What will be the output of the following C++ program? #include <iostream> using namespace std; int main() { #include <cmath> cout << sqrt(25); return 0; } | 25 | Compilation error |
| 2 | What will be the output of the following C++ program? #include <iostream> using namespace std; int main() { cout << "Hello World"; return 0; } | Hello World | Hello World |
| 3 | What will be the output of the following C++ program? #include <iostream> using namespace std; int main() { float x = 5.75; int y = 3; cout << x / y; return 0; } | 1.91 | 1.91 |
| 4 | What will be the output of the following program? #include <iostream> using namespace std; int main() { double d = 5.7; int i = static_cast<int>(d); cout << i; return 0; } | 5 | 5 |
| 5 | What will be the output of the following C++ program? #include <iostream> using namespace std; int main() { const int x = 10; x = 20; cout << x; return 0; } | Compilation Error | Compilation Error |
| 6 | What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int x = 5, y = 3; cout << (x & y); return 0; } | 1 | 1 |
| 7 | What will be the output of the following program? #include <iostream> using namespace std; int main() { int x = 5; cout << ++x << " " << x++ << " " << x; return 0; } | 6 7 7 | 6 6 7 |
| 8 | What will be the output of the following C++ program? #include <iostream> using namespace std; int main() { int x = 10, y = 20; if (x < y) { cout << "x is less than y"; } else if (x > y) { cout << "x is greater than y"; } else { cout << "x is equal to y"; } return 0; } | x is less than y | x is less than y |
| 9 | What will be the output of the following C++ program? #include <iostream> using namespace std; int main() { for (int i = 0; i < 5; i++) { cout << i << " "; } return 0; } | 0 1 2 3 4 | 0 1 2 3 4 |
| 10 | What will be the output of the following C++ program? #include <iostream> using namespace std; int main() { for (int i = 0; i < 5; i++) { if (i == 3) { continue; } cout << i << " "; } return 0; } | 0 1 2 4 | 0 1 2 4 |
| 11 | What will be the output of the following C++ program? #include <iostream> using namespace std; void displayMessage() { cout << "Hello from function!"; } int main() { displayMessage(); return 0; } | Hello from function! | Hello from function! |
| 12 | What will be the output of the following C++ program? #include <iostream> using namespace std; void display(int a) { cout << "Integer: " << a; } void display(double a) { cout << "Double: " << a; } int main() { display(5); display(3.14); return 0; } | Integer: 5 Double: 3.14 | Integer: 5 Double: 3.14 |
| 13 | What will be the output of the following C++ program? #include <iostream> using namespace std; void greet(string name, string message = "Hello") { cout << message << ", " << name; } int main() { greet("Alice"); return 0; } | Hello, Alice | Hello, Alice |
| 14 | What will be the output of the following C++ program? #include <iostream> using namespace std; void countDown(int n) { if (n > 0) { cout << n << " "; countDown(n - 1); } } int main() { countDown(3); return 0; } | 3 2 1 | 3 2 1 |
| 15 | What will be the output of the following C++ program? #include <iostream> using namespace std; inline int square(int x) { return x * x; } int main() { cout << square(5); return 0; } | 25 | 25 |
| 16 | What will be the output of the following C++ program? #include <iostream> using namespace std; void displayMessage() { cout << "Function Pointer Example!"; } int main() { void (*funcPtr)() = displayMessage; funcPtr(); return 0; } | Function Pointer Example! | Function Pointer Example! |
| 17 | What will be the output of the following C++ program? #include <iostream> using namespace std; int main() { auto add = [](int a, int b) { return a + b; }; cout << add(3, 4); return 0; } | 7 | 7 |
| 18 | What will be the output of the following C++ program? #include <iostream> using namespace std; int main() { int arr[3] = {10, 20, 30}; cout << arr[1]; return 0; } | 20 | 20 |
| 19 | What will be the output of the following C++ program? #include <iostream> using namespace std; int main() { int arr[2][3] = {{1, 2, 3}, {4, 5, 6}}; cout << arr[1][2]; return 0; } | 6 | 6 |
| 20 | What will be the output of the following C++ program? #include <iostream> using namespace std; void printArray(int arr[], int size) { for (int i = 0; i < size; i++) { cout << arr[i] << " "; } } int main() { int arr[3] = {1, 2, 3}; printArray(arr, 3); return 0; } | 1 2 3 | 1 2 3 |
| 21 | What will be the output of the following C++ program? #include <iostream> using namespace std; int main() { char str[] = "Hello"; cout << str; return 0; } | Compilation error | Hello |
| 22 | What will be the output of the following C++ program? #include <iostream> #include <string> using namespace std; int main() { string str = "C++ Programming"; cout << str.substr(4, 5); return 0; } | Prog | Prog |
| 23 | What will be the output of the following C++ program? #include <iostream> #include <cstring> using namespace std; int main() { char str1[] = "Hello"; char str2[] = "World"; strcat(str1, str2); cout << str1; return 0; } | Compilation error | HelloWorld |
| 24 | What will be the output of the following C++ program? #include <iostream> #include <sstream> using namespace std; int main() { stringstream ss; ss << "C++" << " " << 2024; string result = ss.str(); cout << result; return 0; } | C++ 2024 | C++ 2024 |
| 25 | What will be the output of the following C++ program? #include <iostream> using namespace std; int main() { int num = 10; int* ptr = # cout << *ptr; return 0; } | Compilation error | 10 |
| 26 | What will be the output of the following C++ program? #include <iostream> using namespace std; int main() { int a = 20; int* p = &a; *p = 30; cout << a; return 0; } | 30 | 30 |
| 27 | What will be the output of the following C++ program? #include <iostream> using namespace std; int main() { int arr[3] = {1, 2, 3}; int* ptr = arr; cout << *(ptr + 1); return 0; } | 2 | 2 |
| 28 | What will be the output of the following C++ program? #include <iostream> using namespace std; int main() { int* ptr = new int(5); cout << *ptr; delete ptr; return 0; } | 5 | 5 |
| 29 | What will be the output of the following C++ program? #include <iostream> using namespace std; int main() { int* ptr = new int(10); // Memory leak, no delete return 0; } | 0 | No output, but there is a memory leak |
| 30 | What will be the output of the following C++ program? #include <iostream> #include <memory> using namespace std; int main() { unique_ptr<int> ptr(new int(100)); cout << *ptr; return 0; } | 100 | 100 |
| 31 | What will be the output of the following C++ program? #include <iostream> using namespace std; void displayMessage() { cout << "Hello from function pointer!"; } int main() { void (*funcPtr)() = displayMessage; funcPtr(); return 0; } | Hello from function pointer! | Hello from function pointer! |
| 32 | What will be the output of the following C++ program? #include <iostream> using namespace std; int main() { const char* arr[] = {"Apple", "Banana", "Cherry"}; cout << arr[1]; return 0; } | Banana | Banana |
| 33 | What will be the output of the following C++ program? #include <iostream> using namespace std; void display(int a) { cout << a << " "; } int main() { void (*funcPtr)(int) = display; int arr[3] = {10, 20, 30}; for (int i = 0; i < 3; i++) { funcPtr(arr[i]); } return 0; } | 10 20 30 | 10 20 30 |
| 34 | What will be the output of the following C++ program? #include <iostream> using namespace std; int main() { int arr[3] = {1, 2, 3}; int* ptr = arr; cout << *(ptr + 2); return 0; } | 3 | 3 |
| 35 | What will be the output of the following C++ program? #include <iostream> using namespace std; class MyClass { public: int x; MyClass() { x = 10; } }; int main() { MyClass obj; cout << obj.x; return 0; } | 10 | 10 |
| 36 | What will be the output of the following C++ program? #include <iostream> using namespace std; class Rectangle { public: int length, width; Rectangle(int l, int w) { length = l; width = w; } }; int main() { Rectangle rect(5, 10); cout << rect.length << " " << rect.width; return 0; } | 5 10 | 5 10 |
| 37 | What will be the output of the following C++ program? #include <iostream> using namespace std; class Circle { public: double radius; void setRadius(double r) { radius = r; } double getArea() { return 3.14 * radius * radius; } }; int main() { Circle c; c.setRadius(5); cout << c.getArea(); return 0; } | 78.5 | 78.5 |
| 38 | What will be the output of the following C++ program? #include <iostream> using namespace std; class Test { public: Test() { cout << "Constructor called" << endl; } ~Test() { cout << "Destructor called" << endl; } }; int main() { Test obj; return 0; } | Constructor called Destructor called | Constructor called Destructor called |
| 39 | What will be the output of the following C++ program? #include <iostream> using namespace std; class MyClass { public: int value; MyClass() { value = 5; } }; int main() { MyClass obj; cout << obj.value; return 0; } | 5 | 5 |
| 40 | What will be the output of the following C++ program? #include <iostream> using namespace std; class Box { public: int length; Box(int l) { length = l; } }; int main() { Box b(10); cout << b.length; return 0; } | 10 | 10 |
| 41 | What will be the output of the following C++ program? #include <iostream> using namespace std; class Animal { public: void sound() { cout << "Animal Sound" << endl; } }; class Dog : public Animal { public: void bark() { cout << "Bark" << endl; } }; int main() { Dog d; d.sound(); d.bark(); return 0; } | Animal Sound Bark | Animal Sound Bark |
| 42 | What will be the output of the following C++ program? #include <iostream> using namespace std; class Complex { public: int real, imag; Complex() : real(0), imag(0) {} Complex operator + (const Complex& c) { Complex temp; temp.real = real + c.real; temp.imag = imag + c.imag; return temp; } void display() { cout << real << " + i" << imag << endl; } }; int main() { Complex c1, c2; c1.real = 5; c1.imag = 3; c2.real = 2; c2.imag = 4; Complex c3 = c1 + c2; c3.display(); return 0; } | 7 + i7 | 7 + i7 |
| 43 | What will be the output of the following C++ program? #include <iostream> using namespace std; int main() { int a = 5, b = 10; cout << (a + b) * (a > b) << endl; return 0; } | 0 | 0 |
| 44 | What will be the output of the following C++ program that checks for an out-of-bounds access on a 2D array? #include <iostream> using namespace std; int main() { int arr[2][2] = {{1, 2}, {3, 4}}; cout << arr[2][2] << endl; // Out of bounds return 0; } | Undefined behavior | Undefined behavior |
| 45 | What will be the output of the following C++ program that reverses each word in a string? #include <iostream> #include <sstream> using namespace std; int main() { string str = "hello world"; stringstream ss(str); string word; while (ss >> word) { reverse(word.begin(), word.end()); cout << word << " "; } return 0; } | olleh dlrow | olleh dlrow |
Page 1