CPA 試験問題を無料オンラインアクセス

試験コード:CPA
試験名称:C++ Certified Associate Programmer
認定資格:C++ Institute
無料問題数:220
更新日:2026-08-29
評価
100%

問題 1

What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
int x,y=10;
float f;
f = 5.20;
x=(int) f;
cout << x <<", ";
f=float (y);
cout << f;
return 0;
}

問題 2

What happens when you attempt to compile and run the following code?
#include <iostream>
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<j;
}

問題 3

What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
class Second;
class Base {
int age;
public:
Base () { age=5; };
friend void set(Base &ob, Second &so);
void Print() { cout << age;}
};
class Second {
string name;
public:
friend void set(Base &ob, Second &so);
void Print() { cout << name;}
};
void set(Base &ob, Second &so) {
ob.age = 0; so.name = "Bill";
}
int main () {
Base a;
Second b;
set(a,b);
a.Print();
b.Print();
return 0;
}

問題 4

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;
}

問題 5

What is the output of the program?
#include <iostream>
#include <string>
using namespace std;
struct Person {
int age;
};
class First
{
Person *person;
public:
First() {person = new Person;
person->age = 20;
}
void Print(){
cout << person->age;
}
};
int main()
{
First t[2];
for (int i=0; i<2; i++)
t[i].Print();
}

コメントを追加

あなたのメールアドレスが公開されることはありません。個人情報に関する内容は隠されます *

insert code
画面にある文字を入力してください。