+ 1
int a,b; a= 1,2,3,4,5; b=(1,2,3,4,5); cout <<a <<b; Outputs: 15 How a and b outputs to 1 and 5 respetively?(It is one of the question in c++ belonging to challenge section) This code will not even get compiled, because a is expected to be an integer and so is b, but what type of a value does b have there ? There should be no outputs but an error.
16th Apr 2018, 1:08 PM
Semih Mumcu
Semih Mumcu - avatar
+ 1
by defining *p1=b , you basically change the variable value that &a carries which is "a". Since *p2 points to the same adress its value gets changed to b as well. Therefore *p1 and *p2 pointers are the same and equal to b which sums up to 13+13=26
14th Apr 2018, 10:14 AM
Semih Mumcu
Semih Mumcu - avatar
+ 1
cout<<a will be 13, because you changed the value to b on whatever was in &a
14th Apr 2018, 10:23 AM
Semih Mumcu
Semih Mumcu - avatar
+ 1
My pleasure ! Nirmalya Bakshi
14th Apr 2018, 10:26 AM
Semih Mumcu
Semih Mumcu - avatar