What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main() {
float i = 1.0 / 2 * 2 / 1 * 2 / 4 * 4 / 2;
cout << i;
return 0;
}
A. It prints: 0
B. It prints: 1
C. It prints: 2
D. It prints: 0.5
What happens when you attempt to compile and run the following code?
#include
using namespace std;
namespace myNamespace1
{
int x = 5;
int y = 10;
}
namespace myNamespace2
{
float x = 3.14;
float y = 1.5;
}
int main () {
{
using namespace myNamespace1;
cout << x << " ";
}{
using namespace myNamespace2;
cout << y;
}
return 0;
}
A. It prints: 5 1.5
B. It prints: 3.14 10
C. Compilation error
D. None of these
What happens when you attempt to compile and run the following code?
#include
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 error
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;
}
A. It prints: 0
B. It prints: 6
C. It prints: 2
D. It prints: 3
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 = andob1;
obj?>Print();
obj = andob2;
obj?>Print();
obj = andob3;
obj?>Print();
}
A. It prints: BBB
B. It prints: AAA
C. It prints: ABC
D. It prints: ABB
What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
class complex{
double re, im;
public:
complex() : re(1),im(0.4) {}
complex operator+(complex andt);
void Print() { cout << re << " " << im; }
};
complex complex::operator+ (complex andt){
complex temp;
temp.re = this?>re + t.re;
temp.im = this?>im + t.im;
return temp;
}
int main(){
complex c1,c2,c3;
c3 = c1 + c2;
c3.Print();
}
A. It prints: 1 0.4
B. It prints: 2 0.8
C. It prints: 0 0
D. Garbage value
What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
const int size = 3;
class A {
public:
string name;
A() { name = "Bob";}
A(string s) { name = s;}
A(A anda) { name = a.name;}
};
class B : public A {
public:
B() { }
B(string s) : A(s) { }
void Print() {
cout << name;
}
};
int main () {
B b1("Alan");
b1.Print();
return 0;
}
A. It prints: 111Alan
B. It prints: Bob
C. It prints: Alan
D. It prints: 0
Which code, inserted at line 15, generates the output "5 Bob"?
#include
using namespace std;
class B;
class A {
int age;
public:
A () { age=5; };
friend void Print(A andob, B andso);
};
class B {
string name;
public:
B () { name="Bob"; };
//insert code here
};
void Print(A andob, B andso) {
cout< } int main () { A a; B b; Print(a,b); return 0; } A. friend void Print(A ob, B so); B. friend void Print(A andob, B andso); C. friend void Print(A *ob, B *so); D. None of these
What happens when you attempt to compile and run the following code?
#include
#include
#include
using namespace std;
int main(void)
{
string s;
s = "Test";
s.resize (s.size() ? 1);
cout<
return 0;
}
A. It prints: Test 4
B. It prints: Test 3
C. Compilation error
D. It prints: Tes 3
What happens when you attempt to compile and run the following code?
#include
using namespace std;
class BaseC
{
int *ptr;
public:
BaseC() { ptr = new int(10);}
BaseC(int i) { ptr = new int(i); }
~BaseC() { delete ptr; }
void Print() { cout << *ptr; }
};
int main()
{
BaseC *o = new BaseC(5);
o?>Print();
}
A. It prints: 5
B. It prints: 10
C. It prints: 1
D. It prints: 0
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-21-02 exam preparations and C++ Institute certification application, do not hesitate to visit our Vcedump.com to find your solutions here.