Free CPA-21-02 Exam Braindumps (page: 20)

Page 20 of 65

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;
}

  1. No error
  2. Error: unknown pointer conversion
  3. cannot convert from 'const int *' to 'int *const'
  4. Compilation error

Answer(s): A



What happens when you attempt to compile and run the following code?

#include <iostream>

using namespace std;

int main()

{
int i=2;
switch(i)
{
case 1:
cout<<"Hello";
case 2:
cout<<"world";
case 3:
cout<<"End";
} return 0;
}

  1. It prints: Hello
  2. It prints: world
  3. It prints: worldEnd
  4. It prints: End

Answer(s): C



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 main(){
complex c1;
double i=2;
c1 = i;
c1.print();
return 0;
}

  1. It prints: 0 0
  2. It prints: 1 1
  3. It prints: 2 0
  4. It prints: 2 2

Answer(s): D



What happens when you attempt to compile and run the following code?

#include <iostream>
#include <string>

using namespace std;

int f(int i, int b);

int main()
{
int i=0;
i++;
for (i=0; i<=2; i++)
{
cout<<f(0,i);
}
return 0;
}

int f(int a, int b)
{
return a+b;
}

  1. It prints: 202020
  2. It prints: 012
  3. It prints: 0
  4. It prints: 2

Answer(s): B



Page 20 of 65



Post your Comments and Discuss C++ Institute CPA-21-02 exam with other Community members:

Subash commented on October 21, 2024
I am planning to take this exam. Are these 257 questions enough to clear it? Also, does each section have a passing percentage, or is it based on the overall ?
INDIA
upvote