Free CPA-21-02 Exam Braindumps
CPA - C++ Certified Associate Programmer Questions 131–135 (page: 28)

Updated On: 9-Feb-2026

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

#include <iostream>
#include <string>

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

  1. It prints: 05
  2. It prints: 012345
  3. It prints: 01245
  4. It prints: 0

Answer(s): C



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

#include <iostream>

using namespace std;

int main()
{
int i = 5;
do {
i??;
cout<<i;

}
while(i >= 0);
return 0;
}

  1. It prints: 43210?1
  2. It prints: ?1
  3. It prints: 4321
  4. It prints: 1

Answer(s): A



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

#include <iostream>
#include <string>

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

  1. It will print: Hello World
  2. It will print: Hello
  3. It will print: World
  4. It will print: HW

Answer(s): A



What is not inherited from the base class?

  1. constructor
  2. destructor
  3. operator=()
  4. operator+()

Answer(s): A,B,C



How many times will the program print "HELLO" ?

#include <iostream>

using namespace std;

int main()
{
cout<<"HELLO";
main();
return 0;
}

  1. 65536
  2. 32769
  3. 1
  4. Till stack overflows

Answer(s): D



Viewing page 28 of 53
Viewing questions 136 - 140 out of 257 questions


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

AI Tutor AI Tutor 👋 I’m here to help!