+ 2

Int a=a×0; cout <<hex <<a;

what is output ??

29th Aug 2018, 1:28 PM
naveen
naveen - avatar
7 Respostas
+ 5
naveen if you are concerned about challenge question, I am sure that it was not having any issue... I guess you made typo in posting this question.... as far as I recall challenge, it was as below : int a = 0xa; cout << hex << a; answer for above is a only...check in playground if you wish... coming to reason behind this is as below: oxa is not multiplication of 0 and a... it give random value (on playground , it gives 0) as a is not assigned value yet... 0x is used to denote that number is hexadecimal... a in hexadecimal stand for value 10... so do check below in code playground and you will get answer as 10. int variable = 0xa; cout << variable ; if we write hex in between cout (cout << hex << variable;) output is a again as int value of variable which is 10 got converted to hexadecimal value a again...
29th Aug 2018, 5:00 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 2
0 should be... I have never seen code like this "Int a = a*0", its just kind of pointless, huh
29th Aug 2018, 2:22 PM
Data
Data - avatar
+ 2
naveen well, i just made a cpp code like this and ran it, and it outputed 0. Report the challenge for wrong answer, you can make a cpp code like this and check for yourself if you want to be sure
29th Aug 2018, 3:01 PM
Data
Data - avatar
+ 2
29th Aug 2018, 6:10 PM
naveen
naveen - avatar
+ 1
actually it is asked in sololearn challenge only.i kept answer as 0 but it shown as wrong answer
29th Aug 2018, 2:51 PM
naveen
naveen - avatar
+ 1
ok Data
29th Aug 2018, 3:07 PM
naveen
naveen - avatar
+ 1
thanks for your help
29th Aug 2018, 3:07 PM
naveen
naveen - avatar