Sail E0 Webinar
Question


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
Options:
A .  10,20,30,40,50,
B .  1020304050
C .  compile error
D .  runtime error
Answer: Option A

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 ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers