C++ Institute CPA - C++ Certified Associate Programmer Exam

Question #6 (Topic: Topic 1)
What will be the output of the program?
#include <iostream>
using namespace std;
int fun(int);
int main()
{
cout << fun(5);
return 0;
}
int fun(int i)
{
return i*i;
}
A. 25 B. 5 C. 0 D. 1
Answer: A
Question #7 (Topic: Topic 1)
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
#define FUN(arg) if(arg) cout<<"Test";
int main()
{
int i=1;
FUN(i<3);
return 0;
}
A. It prints: 0 B. It prints: T C. It prints: T0 D. It prints: Test
Answer: D
Question #8 (Topic: Topic 1)
What will the variable "y" be in class B?
class A {
int x;
protected:
int y;
public:
int age;
};
class B : private A {
string name;
public:
void Print() {
cout << name << age;
}
};
A. public B. private C. protected D. None of these
Answer: B
Question #9 (Topic: Topic 1)
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
float x=3.5,y=1.6;
int i,j=2;
i = x + j + y;
cout << i;
return 0;
}
A. It prints: 7 B. It prints: 6 C. It prints: 7,1 D. Compilation error
Answer: A
Question #10 (Topic: Topic 1)
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main(){
int i = 1;
if (i==1) {
cout << i;
} else {
cout << i-1;
}
return 0;
}
A. It prints: 0 B. It prints: 1 C. It prints: -1 D. It prints: 2
Answer: B
Download Exam
Page: 2 / 44
Total 220 questions