Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute Exam CPA-21-02 Topic 1 Question 17 Discussion

Actual exam question for C++ Institute's CPA-21-02 exam
Question #: 17
Topic #: 1
[All CPA-21-02 Questions]

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

#include

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;

}

Show Suggested Answer Hide Answer
Suggested Answer: D

Contribute your Thoughts:

Micaela
3 days ago
But the code is trying to access a struct person before it's defined, so I still think it's A).
upvoted 0 times
...
Leota
10 days ago
I disagree, I believe the correct answer is C) It prints: Steve 31.
upvoted 0 times
...
Micaela
12 days ago
I think the answer is A) Error: in prototype declaration unknown struct person.
upvoted 0 times
...

Save Cancel