Question
1.
#include
2.
using namespace std;
3.
int main ()
4.
{
5.
int numbers[5];
6.
int * p;
7.
p = numbers; *p = 10;
8.
p++; *p = 20;
9.
p = &numbers[2]; *p = 30;
10.
p = numbers + 3; *p = 40;
11.
p = numbers; *(p + 4) = 50;
12.
for (int n = 0; n < 5; n++)
13.
cout
What is the output of this program?
1.
#include
2.
using namespace std;
3.
int main ()
4.
{
5.
int numbers[5];
6.
int * p;
7.
p = numbers; *p = 10;
8.
p++; *p = 20;
9.
p = &numbers[2]; *p = 30;
10.
p = numbers + 3; *p = 40;
11.
p = numbers; *(p + 4) = 50;
12.
for (int n = 0; n < 5; n++)
13.
cout
Answer: Option A
Was this answer helpful ?
In this program, we are just assigning a value to the array and printing it and immediately dereferencing it.
Output:
$ g++ point4.cpp
$ a.out
10,20,30,40,50,
Was this answer helpful ?
Submit Solution