Free CPA-21-02 Exam Braindumps (page: 19)

Page 19 of 65

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

  1. It prints: 0
  2. It prints: 4.9
  3. It prints: 5
  4. It prints: 4

Answer(s): B



What is the output of the program?

#include <iostream>
#include <string>

using namespace std;

int main()
{
string s1="Hello";
string s2="World";
s1+=s2;
cout << s1;
return( 0 );

}

  1. It prints: HelloWorld
  2. It prints: Hello
  3. It prints: World
  4. It prints: HelWorld

Answer(s): A



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

#include <iostream>

using namespace std;

#define DEF_A 0
#define DEF_B DEF_A+1
#define DEF_C DEF_B+1

int main(int argc, char *argv[]) {
cout << DEF_C;
return 0;
}

  1. It prints: 2
  2. It prints: 10
  3. It prints: 0
  4. It prints: 1

Answer(s): 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;
}

  1. It prints: 18
  2. It prints: 19
  3. It prints: 20
  4. It prints: 0

Answer(s): B



Page 19 of 65



Post your Comments and Discuss C++ Institute CPA-21-02 exam with other Community members:

Subash commented on October 21, 2024
I am planning to take this exam. Are these 257 questions enough to clear it? Also, does each section have a passing percentage, or is it based on the overall ?
INDIA
upvote