Weekend Sale Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: xmas50

C++ Institute CPA-21-02 - CPA - C++ Certified Associate Programmer

Page: 5 / 8
Total 257 questions

Which definitions are correct?

A.

int age;

B.

int double;

C.

char c;

D.

int char;

What will be the output of the program?

#include

#include

using namespace std;

int fun(int);

int main()

{

float k=3;

k = fun(k);

cout<

return 0;

}

int fun(int i)

{

i++;

return i;

}

A.

3

B.

5

C.

4

D.

5

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

#include

using namespace std;

int main()

{

int i = 4;

while(i >= 0) {

cout<

i??;

}

return 0;

}

A.

It prints:”43210”

B.

It prints:”3210”

C.

It prints: ”3210?1”

D.

None of these

What is the expected result of the following program?

A.

It prints: 4

B.

The program enters an infinite loop

C.

It prints: 42

D.

It prints: 420

Which code line instead of the comment below will cause the program to produce the expected output?

A.

a = b * c;

B.

return a = b * c;

C.

return a = b * *c;

D.

a = b * *c;

If there is one, point out an error in the program

#include

using namespace std;

int main()

{

int i=1;

for(;;)

{

cout<

if(i>5)

break;

}

return 0;

}

A.

Error in “if” statement

B.

Error in “for” loop

C.

No error

D.

Error in break statement

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;

}

A.

It prints: 123

B.

It prints: 23

C.

It prints: 3

D.

It prints: 2

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;

}

A.

It prints: 2

B.

It prints: 5

C.

It prints: 10

D.

It prints: 0

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

#include

#include

using namespace std;

int f(int i);

int main()

{

int i=0;

i++;

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

{

cout<

}

return 0;

}

int f(int a)

{

return a+a;

}

A.

It prints: 202020

B.

It prints: 012

C.

It prints: 024

D.

It prints: 0

What is the expected output of the following program?

A.

It prints: 432

B.

It prints: 321

C.

It prints: 4321

D.

It prints: 3210