Free CPA Exam Braindumps
C++ Certified Associate Programmer Questions 106–110 (page: 23)

Updated On: 9-Feb-2026

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

#include <iostream>
using namespace std;

int main() {
float i = 1.0 / 2 * 2 / 1 * 2 / 4 * 4 / 2;
cout << i;
return 0;
}

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

Answer(s): B



What is the output of the program?

#include <iostream>
#include <string>

using namespace std;

class First
{
string name;
public:
First() {
name = "Alan";
}
void Print(){
cout << name;
}
};


int main()
{
First ob1,*ob2;
ob2 = new First();
ob1.Print();
ob2?>Print();
}

  1. Garbage value
  2. It prints: AlanAlan
  3. It prints: Alan
  4. It prints: Al

Answer(s): B



What will the variable "age" 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



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

#include <iostream>
using namespace std;
int main()
{
const int x=20;
const int *ptr;
ptr = &x;
*ptr = 10;
cout<<*ptr;
return 0;
}

  1. It prints: 20
  2. It prints: 10
  3. Compilation error at line 8
  4. It prints address of ptr

Answer(s): C



What is the output of the program given below?

#include <iostream>

using namespace std;

int main (int argc, const char * argv[])
{
int i=10;
{
int i=0;
cout<<i;
}
{
int i=5;
cout << i;
}
cout<<i;
return 0;
}

  1. 1010
  2. 101010
  3. 0510
  4. None of these

Answer(s): C



Viewing page 23 of 45
Viewing questions 111 - 115 out of 220 questions


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

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