0

Int main(){int a; a=31&14+5*sizeof(6.4);printf("%d",a) } output=2 how?????

9th Feb 2020, 7:10 AM
Harsh Vyas
Harsh Vyas - avatar
8 odpowiedzi
+ 2
About the single & it is bitwise AND operator. SoloLearn got a good intro on that subject here https://www.sololearn.com/learn/4070/?ref=app P.S. You can edit your text bro, no need to post a typo fix as another text reply : )
9th Feb 2020, 9:12 AM
Ipang
+ 1
Are you sure the output was 2? I think it's rather 22 though. * Having known the default type used for floating point literal is double, assume sizeof(double) = 8. 31 & 14 + (5 * sizeof(6.4)) 31 & 14 + (5 * 8) 31 & 14 + (40) 31 & (14 + 40) 31 & (54) Final result: 22 Dec Binary 31 00011111 54 00110110 ----------------------- & 22 00010110 I could be wrong though;
9th Feb 2020, 7:51 AM
Ipang
+ 1
It could be the book mistake I don't know but I think your explanation is right thnku
9th Feb 2020, 8:35 AM
Harsh Vyas
Harsh Vyas - avatar
0
I got 22 for output of the code bro ... Try to run it in Code Playground, you'll see ...
9th Feb 2020, 8:39 AM
Ipang
0
Is this type of questions you can expect in your coding test placements
9th Feb 2020, 9:00 AM
Harsh Vyas
Harsh Vyas - avatar
0
Didn't you say "the book mistake"? I don't know about placements, but looks common for a challenge.
9th Feb 2020, 9:03 AM
Ipang
0
What is single & b/w 31 and 44 means
9th Feb 2020, 9:06 AM
Harsh Vyas
Harsh Vyas - avatar
0
14*
9th Feb 2020, 9:06 AM
Harsh Vyas
Harsh Vyas - avatar