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 18 Discussion

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

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

#include

using namespace std;

int main()

{

int *t;

t = new int[2];

for (int i=0; i<2; i++) {

t[i] = i;

}

cout << t[1];

}

Show Suggested Answer Hide Answer
Suggested Answer: A, B

Contribute your Thoughts:

Yolando
6 days ago
I'm not sure, but I think it prints: 1 as well
upvoted 0 times
...
Sharika
10 days ago
I agree with Adelina, because t[1] is assigned the value of 1
upvoted 0 times
...
Adelina
12 days ago
I think it prints: 1
upvoted 0 times
...

Save Cancel