C++ Institute CPA Exam
C++ Certified Associate Programmer (Page 6 )

Updated On: 26-Jan-2026

What is the output of the program?

#include <iostream>
#include <string>

using namespace std;


int main()
{
string s1[]= {"H" , "t" };
string s;

for (int i=0; i<2; i++) {
s = s1[i];
s.insert(1,"ow");
cout << s;
}
return( 0 );
}

  1. It prints: How
  2. It prints: Ht
  3. It prints: Hoto
  4. It prints: Howtow

Answer(s): D



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

#include <iostream>

using namespace std;

int op(int x, int y)
{
int i;
i = x + y;
return i;
}

int main()
{
int i=1, j=2, k, l;
k = op(i, j);
l = op(j, i);
cout<< k << "," << l;
return 0;
}

  1. It prints: 1,2
  2. It prints: ?1,1
  3. It prints: 1,1
  4. It prints: 3,3

Answer(s): D



What will the variable "y" be in class B?

class A {
int x;
protected:
int y;
public:
int age;
};


class B : protected A {
string name;
public:
void Print() {
cout << name << age;
}
};

  1. public
  2. private
  3. protected
  4. None of these

Answer(s): C



Which of the following structures are correct?

1:
struct s1{
int x;
char c;
};

2:
struct s2{
float f;
struct s2 *s;
};

3:
struct s3{
float f;
in i;
}

  1. 1
  2. 2
  3. 3
  4. All of these

Answer(s): A,B



How many times will "HELLO" be printed?

#include <iostream>

using namespace std;

int main()
{
for(int i=?1; i<=10; i++)
{
if(i < 5)
continue;
else
break;
cout<<"HELLO";
}
return 0;
}

  1. 1
  2. 2
  3. 0
  4. 20

Answer(s): C



Viewing page 6 of 45
Viewing questions 26 - 30 out of 220 questions



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

Join the CPA Discussion