What is the output of the program given below?

What is the output of the program given below? #include <iostream> using namespace std; int main (int argc, const char * argv[]) { int i=10; { int i=0; cout<<i; } { i=5; cout << i; } cout<<i; return 0; }A . 1010B . 101010C . 055D . None of theseView...

January 20, 2024 No Comments READ MORE +

What will be the output of the program?

What will be the output of the program? #include <iostream> using namespace std; int fun(int); int main() { cout << fun(5); return 0; } int fun(int i) { return i*i; }A . 25B . 5C . 0D . 1View AnswerAnswer: A

January 19, 2024 No Comments READ MORE +

What happens when you attempt to compile and run the following code?

What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int main() { int x=0; int *ptr; ptr = &x; cout<<x<<" "<<*ptr; return 0; }A . It prints: 0 0B . It prints address of ptrC . It prints: 1D . It prints:...

January 19, 2024 No Comments READ MORE +

What will the variable "y" be in class B?

What will the variable "y" be in class B? class A { int x; protected: int y; public: int age; }; class B: private A { string name; public: void Print() { cout << name << age; } };A . publicB . privateC . protectedD . None of theseView AnswerAnswer:...

January 19, 2024 No Comments READ MORE +

s.resize (s.size() ?

What happens when you attempt to compile and run the following code? #include <iostream> #include <sstream> #include <string> using namespace std; int main(void) { string s; s = "Test"; s.resize (s.size() ? 1); cout<<s<<" "<<s.size(); return 0; }A . It prints: Test 4B . It prints: Test 3C . Compilation...

January 19, 2024 No Comments READ MORE +

What happens when you attempt to compile and run the following code?

What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int main (int argc, const char * argv[]) { int a = 30, b = 1, c = 5, i=10; i = b < a < c; cout << i; return 0; }A...

January 19, 2024 No Comments READ MORE +

person?

What is the output of the program? #include <iostream> #include <string> using namespace std; struct Person { int age; }; class First { Person *person; public: First() {person = new Person; person?>age = 20; } void Print(){ cout << person?>age; } }; int main() { First t[2]; for (int i=0;...

January 19, 2024 No Comments READ MORE +

Which code, inserted at line 10, generates the output "Hello World"?

Which code, inserted at line 10, generates the output "Hello World"? #include <iostream> #include <string> using namespace std; string fun(string, string); int main() { string s="Hello"; string *ps; ps = &s; //insert code here return 0; } string fun(string s1, string s2) { return s1+s2; }A . cout << fun("...

January 19, 2024 No Comments READ MORE +

return s(n?

What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int s(int n); int main() { int a; a = 3; cout << s(a); return 0; } int s(int n) { if(n == 0) return 1; return s(n?1)*n; }A . It prints: 4B...

January 19, 2024 No Comments READ MORE +

What happens when you attempt to compile and run the following code?

What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; class BaseClass { public: int *ptr; BaseClass(int i) { ptr = new int(i); } ~BaseClass() { delete ptr; delete ptr;} void Print() { cout << *ptr; } }; void fun(BaseClass x); int main()...

January 19, 2024 No Comments READ MORE +