CPA-21-02 Exam Details

  • Exam Code
    :CPA-21-02
  • Exam Name
    :CPA - C++ Certified Associate Programmer
  • Certification
    :C++ Institute Certifications
  • Vendor
    :C++ Institute
  • Total Questions
    :257 Q&As
  • Last Updated
    :May 30, 2026

C++ Institute CPA-21-02 Online Questions & Answers

  • Question 171:

    Which code, inserted at line 12, generates the output "5b"? #include using namespace std; namespace myNamespace1 { int var = 5; } namespace myNamespace2 { char var = 'b'; } int main () { //insert code here return 0; }

    A. cout
    B. cout
    C. cout
    D. None of these

  • Question 172:

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

    using namespace std;

    int op(int x, int y);

    int main()

    {

    float *pf;

    float f=0.9;

    pf=andf;

    cout << op(1, *pf);

    return 0;

    }

    int op(int x, int y)

    {

    return x*y;

    }

    A. It prints: 0
    B. It prints: 0.5
    C. It prints: 1
    D. It prints: ?1

  • Question 173:

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

    #include

    #include

    using namespace std;

    class A {

    int x;

    protected:

    int y;

    public:

    int z;

    A() { x=1; y=2; z=3; }

    };

    class B : public A {

    string z;

    public:

    void set() { y = 4; z = "John"; }

    void Print() { cout << y << A::z; }

    };

    int main () {

    B b;

    b.set();

    b.Print();

    return 0;

    }

    A. It prints: 4John
    B. It prints: 2John
    C. It prints: 23
    D. It prints: 43

  • Question 174:

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

    A. int main (int argc, char *argv[])
    B. int main (int c, char *v[])
    C. int main
    D. void main ()

  • Question 175:

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

    A. It prints: AAABDD
    B. It pints: AABD
    C. It prints: AABDD
    D. It causes a compilation error

  • Question 176:

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

    #include

    using namespace std;

    #define DEF_A 0 #define

    DEF_B DEF_A+1 #define

    DEF_C DEF_B+1

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

    cout << DEF_C;

    return 0;

    }

    A. It prints: 2
    B. It prints: 10
    C. It prints: 0
    D. It prints: 1

  • Question 177:

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

    A. It prints: 10
    B. It prints: 2+32+3
    C. It prints: 7
    D. It prints: 22+3

  • Question 178:

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

    #include

    using namespace std;

    void fun(char*);

    int main()

    {

    char t[4]={'0', '1', '2', '3'};

    fun(andt[2]);

    return 0;

    }

    void fun(char *a)

    {

    cout << *a;

    }

    A. It prints: 2
    B. It prints: 21
    C. It prints: 00
    D. It prints: 02

  • Question 179:

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

    #include

    class complex{

    double re;

    double im;

    public:

    complex() : re(0),im(0) {}

    complex(double x) { re=x,im=x;};

    complex(double x,double y) { re=x,im=y;}

    void print() { cout << re << " " << im;}

    };

    int main(){

    complex c1(1,2);

    c1.print();

    return 0;

    }

    A. It prints: 1 0
    B. It prints: 1 1
    C. It prints: 1 2
    D. Compilation error

  • Question 180:

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

    #include

    using namespace std;

    void set(struct person*);

    struct person

    {

    char name[25];

    int age;

    };

    int main()

    {

    struct person e = {"Steve", 30};

    set(ande);

    cout<< e.name << " " << e.age;

    return 0;

    }

    void set(struct person *p)

    { p?>age = p?>age + 1; }

    A. Error: in prototype declaration unknown struct person
    B. Error: in structure
    C. It prints: Steve 31
    D. None of these

Tips on How to Prepare for the Exams

Nowadays, the certification exams become more and more important and required by more and more enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare for the exam in a short time with less efforts? How to get a ideal result and how to find the most reliable resources? Here on Vcedump.com, you will find all the answers. Vcedump.com provide not only C++ Institute exam questions, answers and explanations but also complete assistance on your exam preparation and certification application. If you are confused on your CPA-21-02 exam preparations and C++ Institute certification application, do not hesitate to visit our Vcedump.com to find your solutions here.