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 CPA-21-02 Exam - Topic 6 Question 59 Discussion

What happens when you attempt to compile and run the following code?#include using namespace std;void fun(int*);int main(){int i=2;fun(&i);cout
B) It prints: 4
A) It prints: 1
C) It prints: 10
D) It prints: 0

C++ Institute CPA-21-02 Exam - Topic 6 Question 59 Discussion

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

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

#include

using namespace std;

void fun(int*);

int main()

{

int i=2;

fun(&i);

cout<

return 0;

}

void fun(int *i)

{

*i = *i**i;

}

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

0/2000 characters
Latricia
5 hours ago
I think the function modifies the value of `i`, but I'm not sure what the final output will be.
upvoted 0 times
...

Save Cancel