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(1,2);
c1.print();
return 0;
}
A. It prints: 1 0
B. It prints: 1 1
C. It prints: 1 2
D. Compilation error
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int fun(int x) {
return x<<2;
}
int main(){
int i;
i = fun(1) / 2;
cout << i;
return 0;
}
A. It prints: 0
B. It prints: 1
C. It prints: 2
D. It prints: 4
What will the variable "age" 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. public
B. private
C. protected
D. None of these
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int x=5;
static int y;
int i=0;
void static myFunction()
{
y=x++ + ++i;
}
int main (int argc, const char * argv[])
{
x++;
myFunction();
cout< } A. Compilation fails B. It prints: 5 5 0 C. It prints: 7 7 1 D. It prints: 6 5 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=andtab[0]; cout<<*p;
return 0; }
A. It prints: 10
B. It prints: 20
C. It prints: 11
D. It prints: 30
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int fun(int x) {
return 2*x;
}
int main(){
int i;
i = fun(1) and fun(0);
cout << i;
return 0;
}
A. It prints: 0
B. It prints: 1
C. It prints: -1
D. Compilation error
What happens when you attempt to compile and run the following code?
#include
using namespace std;
class A {
public:
virtual void Print()=0;
};
class B:public A {
public:
virtual void Print() { cout<< "B"; }
};
class C:public A {
public:
virtual void Print() { cout<< "C"; }
};
int main()
{
B ob2;
C ob3;
A *obj;
obj = andob2;
obj?>Print();
obj = andob3;
obj?>Print();
}
A. It prints: BC
B. It prints: CB
C. It prints: CC
D. It prints: BB
What happens when you attempt to compile and run the following code?
#include
#include
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;
f = sum(a,b);
cout<<*f;
return 0;
}
A. It prints: 0
B. It prints: 4.9
C. It prints: 5
D. It prints: 4
Which statement should be added in the following program to make work it correctly?
using namespace std;
int main (int argc, const char * argv[])
{
cout<<"Hello";
}
A. #include
B. #include
C. #include
D. #include
What happens when you attempt to compile and run the following code? #include
using namespace std;
#define FUN(arg) if(arg) cout<<"Test";
int main()
{
int i=1;
FUN(i<3);
return 0;
}
A. It prints: 0
B. It prints: T
C. It prints: T0
D. It prints: Test
Nowadays, the certification exams become more and more important and required by more and more enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare for the exam in a short time with less efforts? How to get a ideal result and how to find the most reliable resources? Here on Vcedump.com, you will find all the answers. Vcedump.com provide not only C++ Institute exam questions, answers and explanations but also complete assistance on your exam preparation and certification application. If you are confused on your CPA exam preparations and C++ Institute certification application, do not hesitate to visit our Vcedump.com to find your solutions here.