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 51:

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

    A. ob2.A::print();
    B. ob2 ?gt; A::print();
    C. ob2.B::print();
    D. ob2 ?gt; B::print();

  • Question 52:

    What is the output of the program?

    #include

    #include

    using namespace std;

    int main()

    {

    string s1[]= {"H" , "t" };

    string s;

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

    s = s1[i];

    if (i==0)

    s.insert(1,"ow");

    else

    s.push_back('o');

    cout << s;

    }

    return( 0 );

    }

    A. It prints: Hoto
    B. It prints: Ht
    C. It prints: toHo
    D. It prints: Howto

  • Question 53:

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

    #include

    using namespace std;

    int main() {

    float i = 1.0 / 2 * 2 / 1 * 2 / 4 * 4 / 2;

    cout << i;

    return 0;

    }

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

  • Question 54:

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

    #include

    using namespace std;

    class A {

    public :

    void print() {

    cout << "A ";

    }

    };

    class B {

    public :

    void print() {

    cout << "B ";

    }

    };

    int main() {

    B sc[2];

    B *bc = (B*)sc;

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

    (bc++)->print();

    return 0;

    }

    A. It prints: A A
    B. It prints: B B
    C. It prints: A B
    D. It prints: B A

  • Question 55:

    Which code, inserted at line 10, generates the output "Hello World"? #include

    #include

    using namespace std;

    string fun(string, string);

    int main()

    {

    string s="Hello";

    string *ps;

    ps = ands;

    //insert code here

    return 0;

    }

    string fun(string s1, string s2)

    {

    return s1+s2;

    }

    A. cout
    B. cout
    C. cout
    D. cout

  • Question 56:

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

    #include

    using namespace std; int compare(int, int);

    int main()

    {

    int x = compare(10, 20);

    cout << x;

    return 0;

    }

    int compare(int i, int j)

    {

    return i

    }

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

  • Question 57:

    Which of the following is a user defined data type?

    1:

    struct person

    {

    char name[20];

    int age;

    };

    2:

    int l=2;

    3:

    enum color {red,blue, green};

    A. 1
    B. 2
    C. 3
    D. 4

  • Question 58:

    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

  • Question 59:

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

    #include

    using namespace std;

    int main(){

    int i, j;

    for(i = 0, j = 1; j < 2, i < 4; i++, j++);

    cout << i << " " << j;

    return 0;

    }

    A. It prints: 4 5
    B. It prints: 2 3
    C. It prints: 3 2
    D. It prints: 4 3

  • Question 60:

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

    #include

    using namespace std;

    #define DEF_A 0

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

    cout << DEF_A;

    return 0;

    }

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

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.