+ 2
Int a=a×0; cout <<hex <<a;
what is output ??
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...
+ 2
0 should be... I have never seen code like this "Int a = a*0", its just kind of pointless, huh
+ 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
+ 2
Ketan Lalcheta thank u
+ 1
actually it is asked in sololearn challenge only.i kept answer as 0 but it shown as wrong answer
+ 1
ok Data
+ 1
thanks for your help