b?
Which code, inserted at line 8, generates the output "0102020"? #include <iostream> using namespace std; class Base { static int age; public: Base () {}; ~Base () {}; //insert code here void Print() { cout << age;} }; int Base::age=0; int main () { Base a,*b; b = new Base();...
Point out an error in the program.
Point out an error in the program. #include <iostream> using namespace std; int main() { char s1[] = "Hello"; char s2[] = "world"; char *const ptr = s1; *ptr = 'a'; ptr = s2; return 0; }A . No errorB . Cannot modify a const objectC . Compilation error at...
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 op(int x, int y); int main() { float *pf; float f=0.9; pf=&f; cout << op(1, *pf); return 0; } int op(int x, int y) { return x*y; }A . It prints: 0B...
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 complex{ double re; double im; public: complex() : re(0),im(0) {} complex(double x) { re=x,im=x;}; complex(double x,double y) { re=x,im=y;} void print() { cout << re << " " << im;} }; int...
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 errorB . Error: unknown pointer conversionC . cannot convert from 'const int *' to 'int *const'D . Compilation errorView AnswerAnswer: A
What is the output of the program?
What is the output of the program? #include <iostream> #include <string> using namespace std; int main() { string s1[]= {"Hello" , "World" }; for (int i=0; i<2; i++) { cout << s1[i]; } return (0); }A . It prints: HelloWorldB . It prints: HelloC . It prints: WorldHelloD . It...
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; }; class B: public A { string name; public: void set() { y = 2; z = 3; } void...
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,y=10; float f; f = 5.20; x=(int) f; cout << x <<", "; f=float (y); cout << f; return 0; }A . It prints: 5, 10B . It...
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 <cstdlib> #include <iostream> using namespace std; float* sum(float a,float b); float* sum(float a,float b) { float *f = new float; *f = a+b; return f; } int main() { float a,b,*f; a = 1.5; b = 3.4;...
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; const int size = 3; class A { public: string name; A() { name = "Bob";} A(string s) { name = s;} A(A &a) { name = a.name;} }; class B:...