+ 2
This question ask in c++ quiz. "What is output of this code (<array> included) ?"
16 Answers
+ 18
<array> header file should be included.
In question it is said that assume it to be included
check this out 👇 now it will work
https://code.sololearn.com/cPKD1Ngq8FTX/?ref=app
+ 14
the answer will be 9
int main() {
array<int,5>arr={0,2,1,3,5};
int *x; // declaration of a pointer x...
x=&arr[3]; //pointer x is pointed to arr[3] therefore the value of *x becomes 3 ( *x=3)
*x+=5; // *x=*x+5=8 ..... as pointer x is pointing to arr[3] with & operator as value of *x changes value of arr[3] also changes ... so now arr[3]=8...
cout<<arr[3]+arr[2]; // 8+1 = 9
return 0;
}
+ 1
The code has some errors:
0) x*+=5 is an invalid operation. It should be *x+=5.
1) x[3] points to arr+6, which is an invalid location and has no data at all. So it will return a random value.
So maybe the challenge was wrong? Just mark it with a wrong answer.
+ 1
i had checked I had taken photo also.
+ 1
screen shot not possible in sololearn but if you provide your email id then I will send.
+ 1
This question ask in c++ quiz. "What is output of this code (<array> included) ?"
https://code.sololearn.com/c2l65KXVK06g/?ref=app
+ 1
https://drive.google.com/file/d/1CeUbbH9xfxk2RyWOhrv_rBFiE-4INZPD/view?usp=drivesdk
+ 1
above link is the screen shot
+ 1
why this program is not run in sololearn
+ 1
thank you
0
this the code ask in c++ solo learn quiz and when I run this code I got error, so what we consider it's output " no output" or any other ?
0
can any one help me about this quiz question ? I am waiting.
0
This question ask in c++ quiz. "What is output of this code (<array> included) ?"
https://code.sololearn.com/c2l65KXVK06g/?ref=app
0
https://drive.google.com/file/d/1CeUbbH9xfxk2RyWOhrv_rBFiE-4INZPD/view?usp=drivesdk
0
@DT
That was x[3] + x[2], which you replaced with arr[3] + arr[2], and thats what corrected the code. But I don't know what was in the challenge though.