최신 CPA 무료덤프 - C++ Institute C++ Certified Associate Programmer

What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
class complex{
double re, im;
public:
complex() : re(1),im(0.3) {}
complex(double n) { re=n,im=n;};
complex(int m,int n) { re=m,im=n;}
complex operator+(complex &t);
void Print() { cout << re << " " << im; }
};
complex complex::operator+ (complex &t){
complex temp;
temp.re = this->re + t.re;
temp.im = this->im + t.im;
return temp;
}
int main(){
complex c1(1),c2(2),c3;
c3 = c1 + c2;
c3.Print();
}

정답: D
What is the output of the program?
#include <iostream> #include <string>
using namespace std;
struct t { int tab[2];
};
class First
{
struct t u;
public:
First() {
u.tab[0] = 1;
u.tab[1] = 0;
}
void Print(){
cout << u.tab[0] << " " << u.tab[1];
}
};
int main()
{
First t;
t.Print();
}

정답: B
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
void set(struct person*);
struct person
{
char name[25];
int age;
};
int main()
{
struct person e = {"Steve", 30};
set(&e);
cout<< e.name << " " << e.age;
return 0;
}
void set(struct person *p)
{
p->age = p->age + 1;
}

정답: C
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int x=5;
static int y=0;
void myFunction(int a)
{
y=++a;
}
int main (int argc, const char * argv[])
{
int i=0;
myFunction(i);
cout<<y<<" "<<x;
}

정답: D
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
int a=5;
cout << ((a < 5) ? 9.9 : 9);
}

정답: A
Which of the structures is incorrect?
1:
struct s1{ int x;
long int li; };
2:
struct s2{ float f; struct s2 *s;
};
3:
struct s3{ float f; struct s3 s;
};

정답: C
What will the variable "y" be in class B?
class A {
int x;
protected:
int y;
public:
int age;
};
class B : protected A {
string name;
public:
void Print() {
cout << name << age;
}
};

정답: C
What is the output of the program given below?
#include <iostream>
using namespace std;
int main (int argc, const char * argv[])
{
int i=10;
{
int i=0;
cout<<i;
}
cout<<i;
return 0;
}

정답: A
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
class A {
protected:
int y;
public:
int x;
int z;
A() { x=1; y=2; z=3; }
A(int a, int b) : x(a), y(b) { z = x * y;}
void Print() {
cout << z;
}
};
int main () {
A a(2,5);
a.Print();
return 0; }

정답: D
What happens when you attempt to compile and run the following code?
#include <cstdlib> #include <iostream>
using namespace std;
inline float sum(float a,float b)
{
return a+b;
}
int main()
{
float a,b;
a = 1.5; b = 3.4;
cout<<sum(a,b);
return 0;
}

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

정답: B
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s1[]= {"H" , "t" };
string s;
for (int i=0; i<2; i++) {
s = s1[i];
s.insert(1,"o");
cout << s; } return( 0 ); }

정답: A
What will be the output of the program?
#include <iostream>
#include <string>
using namespace std;
int fun(int);
int main()
{
float k=3;
k = fun(k);
cout<<k;
return 0;
}
int fun(int i)
{
i++;
return i;
}

정답: A
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
void set(struct person*);
struct person
{
int age;
};
int main()
{
struct person e = {18};
set(&e);
cout<< e.age;
return 0;
}
void set(struct person *p)
{
p->age = p->age + 1;
}

정답: D
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
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 << z;
}
};
int main () {
B b;
b.set();
b.Print();
return 0;
}

정답: C
What is the output of the program?
#include <iostream> #include <string>
using namespace std;
class First
{
string name;
public:
First() {
name = "Alan";
}
void setName(string n) {this->name = n;}
void setName() {this->name = "John";}
void Print(){
cout << name;
}
};
int main()
{
First ob1,*ob2;
ob2 = new First();
First *t;
t = &ob1;
t->setName();
t->Print();
t = ob2;
t->setName("Steve");
ob2->Print();
}

정답: B
What will happen when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
int fun(int);
int main()
{
int *x = new int;
*x=10;
cout << fun(*x);
return 0;
}
int fun(int i)
{
return i*i;
}

정답: C
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
namespace myNamespace1
{
int x = 5;
int y = 10;
}
namespace myNamespace2
{
float x = 3.14;
float y = 1.5;
}
int main () {
{
using namespace myNamespace1;
cout << x << " ";
}{
using namespace myNamespace2;
cout << y;
}
return 0;
}

정답: B
Point out an error in the program.
#include <iostream>
using namespace std;
int main()
{
const int x=1;
int const *y=&x;
cout<<*y;
return 0;
}

정답: C

우리와 연락하기

문의할 점이 있으시면 메일을 보내오세요. 12시간이내에 답장드리도록 하고 있습니다.

근무시간: ( UTC+9 ) 9:00-24:00
월요일~토요일

서포트: 바로 연락하기