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 i = 1; if (i==1) { cout << i; } else { cout << i-1; } return 0; }A . It prints: 0 B.It prints: 1 C.It prints: -1 D.It...

July 1, 2023 No Comments READ MORE +

Point out an error in the program.

Point out an error in the program. #include <iostream> using namespace std; int main() { const int x=1; int const *y=&x; cout<<*y; return 0; }A . No error B.Error: unknown pointer conversion C.cannot convert from 'const int *' to 'int *const' D.Compilation errorView AnswerAnswer: A

June 30, 2023 No Comments READ MORE +

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 . 1010 B.101010 C.055 D.None of theseView AnswerAnswer: C

June 30, 2023 No Comments READ MORE +

p?>age = p?

What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; void set(struct person*); struct person { int age; }; int main() { struct person e = {18}; set(&e); cout<< e.age; return 0; } void set(struct person *p) { p?>age = p?>age + 1;...

June 30, 2023 No Comments READ MORE +

How could you pass arguments to functions?

How could you pass arguments to functions?A . by value B.by reference C.by pointer D.by voidView AnswerAnswer: A,B,C

June 30, 2023 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 First { public: void Print(){ cout<<"from First";} }; class Second { public: void Print(){ cout<< "from Second";} }; int main() { First FirstObject; FirstObject.Print(); Second SecondObject; SecondObject.Print(); }A . It prints: from...

June 30, 2023 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 x=5; static int y=0; void myFunction(int a) { y=++a; } int main (int argc, const char * argv[]) { int i=0; myFunction(i); cout<<y<<" "<<x; }A . It prints: 0 5 B.It prints:...

June 30, 2023 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 fun(int x); int main() { cout << fun(0); return 0; } int fun(int x) { if(x > 0) return fun(x-1); else return 100; }A . It prints: 0 B.It prints: 10 C.It...

June 30, 2023 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> #include <string> using namespace std; class A { int x; protected: int y; public: int z; A() { x=1; y=2; z=3; } }; class B : public A { string z; public: void set() { y...

June 30, 2023 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() { float x=3.5,y=1.6; int i,j=2; i = x + j + y; cout << i; return 0; }A . It prints: 7 B.It prints: 6 C.It prints: 7,1 D.Compilation errorView AnswerAnswer:...

June 30, 2023 No Comments READ MORE +