-
What is the output of this program?
#include
using namespace std;
int main ()
{
int num[5];
int * ptr;
ptr = num; *ptr = 12;
ptr++; *ptr = 21;
ptr = &num[2]; *ptr = 35;
ptr = num + 3; *ptr = 14;
ptr = num; *(ptr + 4) = 53;
for (int k = 0; k < 5; k++)
cout << num[k] << ",";
return 0;
}
-
- 12,21,35,14,53,
- 35,14,53,
- 14,53,
- 12,21,35,14
- 12,21
Correct Option: A
In this program, we are just assigning a value to the array and printing it and immediately dereferencing it.