What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
int mult(int f, int s, int t);
int main()
{
cout << mult(1,2,3);
return 0;
}
int mult(int f, int s, int t)
{
int mult_res;
mult_res = f*s*t;
return mult_res;
}
What happens when you attempt to compile and run the following code?
#include
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 main(){
complex c1;
double i=2;
c1 = i;
c1.print();
return 0;
}
What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
class A {
public:
int x;
};
class B : public A {
public:
B() { x=1;}
B(int x) {this?>x = x;}
};
int main () {
B c1;
B c2(10);
cout << c1.x;
cout << c2.x;
return 0;
}
What happens when you attempt to compile and run the following code?
#include
#include
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 Print() { cout << y << z; }
};
int main () {
B b;
b.set();
b.Print();
return 0;
}
Which of the structures is incorrect?
1:
struct s1{
int x;
long int li;
};
2:
struct s2{
float f;
struct s2 *s;
};
3:
struct s3{
float f;
struct s3 s;
};
What happens when you attempt to compile and run the following code?
#include
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;
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main()
{
int *t;
t = new int[2];
for (int i=0; i<2; i++) {
t[i]=0;
}
cout << t[1];
}
What is the output of the program?
#include
using namespace std;
int main()
{
int tab[4]={10,20,30,40};
tab[1]=10;
int *p;
p=&tab[0];
cout<<*p;
return 0;
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
struct {
int x;
char c;
union {
float f;
int i;
};
} s;
int main (int argc, const char * argv[])
{
s.x=10;
s.i=0;
cout << s.i << " " << s.x;
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
class A
{
public:
void Print(){ cout<<"A";}
};
class B:public A
{
public:
void Print(){ cout<< "B";}
};
int main()
{
A *obj;
A ob1;
obj = &ob1;
obj?>Print();
B ob2;
obj = &ob2;
obj?>Print();
}
What is the output of the program?
#include
#include
using namespace std;
int main()
{
string s1="Hello";
string s2="World";
s1+=s2;
cout << s1;
return( 0 );
}
What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
class A {
public:
A() { cout << "A no parameters";}
A(string s) { cout << "A string parameter";}
A(A &a) { cout << "A object A parameter";}
};
class B : public A {
public:
B() { cout << "B no parameters";}
B(string s) { cout << "B string parameter";}
};
int main () {
A a2("Test");
B b1("Alan");
B b2(b1);
return 0;
}
What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
inline float sum(float a,float b)
{
return a+b;
}
int main()
{
float a,b;
a = 1.5; b = 3.4;
cout< return 0; }
How could you pass arguments to functions?
What happens when you attempt to compile and run the following code?
#include
using namespace std;
void fun(char*);
int main()
{
char t[4]={'0', '1', '2', '3'};
fun(&t[2]);
return 0;
}
void fun(char *a)
{
cout << *a;
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
class A {
public:
void Print(){ cout<<"A"; }
};
class B:public A {
public:
virtual void Print(){ cout<< "B"; }
};
class C:public B {
public:
void Print(){ cout<< "C"; }
};
int main()
{
A ob1;
B ob2;
C ob3;
A *obj;
obj = &ob1;
obj?>Print();
obj = &ob2;
obj?>Print();
obj = &ob3;
obj?>Print();
}
Which of the following can be checked in a switch?case statement?
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int f(int a, int b);
int main()
{
float b;
b = f(20,10);
cout << b;
return 0;
}
int f(int a, int b)
{
return a/b;
}
What is the output of the program?
#include
using namespace std;
#define PRINT(i) cout<
int main()
{
int y=2, z=3;
PRINT(y);
PRINT(z);
return 0;
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
class First
{
public:
First() { cout << "Constructor";}
void Print(){ cout<<"from First";}
};
int main()
{
First FirstObject;
FirstObject.Print();
}
What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
class A {
protected:
int y;
public:
int x, z;
A() : x(1), y(2), z(0) {}
A(int a, int b) : x(a), y(b) { z = x * y;}
void Print() { cout << z; }
};
class B : public A {
public:
int y;
B() : A() {}
B(int a, int b) : A(a,b) {}
void Print() { cout << z; }
};
int main () {
A b(2,5);
b.Print();
return 0;
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
void print(char *c);
int main (int argc, const char * argv[])
{
print("Test");
return 0;
}
void print(char *c)
{
cout< }
What happens when you attempt to compile and run the following code?
#include
using namespace std;
void set(struct person*);
struct person
{
char name[25];
int age;
};
int main()
{
struct person e = {"Steve", 30};
set(&e);
cout<< e.name << " " << e.age;
return 0;
}
void set(struct person *p)
{
p?>age = p?>age + 1;
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main(){
int i = 1;
if (i++==1) {
cout << i;
} else {
cout << i-1;
}
return 0;
}
What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
class SampleClass
{
string *s;
public:
SampleClass() { s = new string("Text");}
SampleClass(string s) { this?>s = new string(s);}
~SampleClass() { delete s;}
void Print(){ cout<<*s;}
};
int main()
{
SampleClass *obj;
obj = new SampleClass("Test");
obj?>Print();
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int min(int a, int b);
int main()
{
int b=10;
b = min(5,20);
cout << b;
return 0;
}
int min(int a, int b)
{
if (a
return(a);
else
return(b);
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main()
{
int i=5;
switch(i)
{
case 1:
cout<<"Hello";
break;
case 2:
cout<<"world";
break;
case 3:
break;
default:
cout<<"End";
}
return 0;
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main() {
int i, j;
for(i = 0; i < 2; i++) {
for(j = i; j < i + 1; j++)
if(j == i)
continue;
else
break;
}
cout << j;
return 0;
}
Which definitions are correct?
What will happen when you attempt to compile and run the following code?
#include
#include
using namespace std;
int fun(int);
int main()
{
int *x = new int;
*x=10;
cout << fun(*x);
return 0;
}
int fun(int i)
{
return i*i;
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
class A
{
public:
virtual void Print(){ cout<<"A";}
};
class B:public A
{
public:
virtual void Print(){ cout<< "B";}
};
int main()
{
A *obj;
A ob1;
obj = &ob1;
obj?>Print();
B ob2;
obj = &ob2;
obj?>Print();
}
Which code, inserted at line 8, generates the output "100"?
#include
using namespace std;
int fun(int);
int main()
{
int *x = new int;
*x=10;
//insert code here
return 0;
}
int fun(int i)
{
return i*i;
}
What will be the output of the program?
#include
using namespace std;
int main()
{
int i=0;
for(; i<=5; i++)
cout << i;
return 0;
}