Pass the C++ Institute C++ Certified Professional Programmer CPA-21-02 Questions and answers with CertsForce

Viewing page 1 out of 8 pages
Viewing questions 1-10 out of questions
Questions # 1:

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

#include

using namespace std;

void fun(int*);

int main()

{

int *x;

int i=2;

x=&i;

fun(x);

cout<

return 0;

}

void fun(int *i)

{

*i = *i * *i;

}

Options:

A.

It prints: 2


B.

It prints: 4


C.

It prints: 0


D.

It prints: 1


Expert Solution
Questions # 2:

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

Question # 2

Options:

A.

It prints: 1


B.

It causes a compilation error


C.

It prints: 0


D.

It prints: My exception,


Expert Solution
Questions # 3:

What is the output of the program if characters 'h', 'e', 'l', 'l' , 'o' and enter are supplied as input?

#include

#include

using namespace std;

void f();

int main()

{

f();

return 0;

}

void f()

{

char c;

c = cin.get();

cout << c;

if(c != '\n')

f();

}

Options:

A.

It prints: hello


B.

It prints: olleh


C.

It prints: h


D.

It prints: o


Expert Solution
Questions # 4:

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

#include

#include

using namespace std;

void fun(int i);

int main()

{

int i=0;

i++;

for (i=0; i<=5; i++)

{

fun(i);

}

return 0;

}

void fun(int i)

{

if (i==3)

return;

cout << i;

}

Options:

A.

It prints: 05


B.

It prints: 012345


C.

It prints: 01245


D.

It prints: 0


Expert Solution
Questions # 5:

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

Question # 5

Options:

A.

It prints: 1


B.

It causes a compilation error


C.

It prints: -1


D.

It prints: 0


Expert Solution
Questions # 6:

What will be the output of the program?

#include

using namespace std;

int main()

{

const int y = 5;

const x = ?10;

cout<

return 0;

}

Options:

A.

?10 5


B.

5 ?10


C.

Compilation error


D.

None of these


Expert Solution
Questions # 7:

Which code lines inserted independently instead of the comment will make the following program work correctly? (Choose three.)

Question # 7

Options:

A.

int main (int argc, char *argv[])


B.

int main (int c, char *v[])


C.

int main


D.

void main ()


Expert Solution
Questions # 8:

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

#include

using namespace std;

class A {

public:

void Print(){ cout<<"A";}

};

class C:public A {

public:

virtual void Print()=0;

};

int main()

{

C obj3;

obj3?>Print();

}

Options:

A.

It prints: BB


B.

It prints: A


C.

It prints: AB


D.

Compilation error


Expert Solution
Questions # 9:

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

Question # 9

Options:

A.

It prints: 10


B.

It prints: 2+32+3


C.

It prints: 7


D.

It prints: 22+3


Expert Solution
Questions # 10:

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

#include

#include

using namespace std;

string fun(string, string);

int main()

{

string s="Hello";

cout << fun(s, " World");

return 0;

}

string fun(string s1, string s2)

{

return s1+s2;

}

Options:

A.

It will print: Hello World


B.

It will print: Hello


C.

It will print: World


D.

It will print: HW


Expert Solution
Viewing page 1 out of 8 pages
Viewing questions 1-10 out of questions