CPA-21-02 Exam Questions & Answers
CPA - C++ Certified Associate Programmer Exam • C++ Institute
100% money-back guarantee
Sample CPA-21-02 Questions
Practice with real exam-style questions, each with the verified correct answer and explanation.
What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
int f(int i, int b);
int main()
{
int i=0;
i++;
for (i=0; i<=2; i++)
{
cout< } return 0; } int f(int a, int b) { return a+b; }
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int fun(int x) {
return 2*x;
}
int main(){
int i;
i = fun(1) || fun(2);
cout << i;
return 0;
}
What is the output of the program?
#include
using namespace std;
class Base {
static int age;
public:
Base () {};
~Base () {};
void setAge(int a=10) {age = a;}
void Print() { cout << age;}
};
int Base::age=0;
int main () {
Base a,*b;
b = new Base();
a.setAge();
b?>setAge(20);
a.Print();
b?>Print();
return 0;
}
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;
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main()
{
int x=2, *y, z=3;
y = &z;
cout< return 0; }
Get access to all 257 verified questions with detailed answers.
Unlock All CPA-21-02 Questions