Why the output print 70 instead of 106? Can you explain | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why the output print 70 instead of 106? Can you explain

#include <stdio.h> int main() { int var=0101; var=var+5; printf("%d",var); return 0; }

12th Feb 2019, 3:02 AM
Shaik Abeedh
Shaik Abeedh - avatar
2 Answers
+ 6
0 is an octal literal, so 0101 would be 8^0 + 8^2 = 65 in decimal. Then you add 5 so thats 70.
12th Feb 2019, 3:53 AM
Jhon
Jhon - avatar
0
27th Apr 2021, 4:38 AM
Themanshri
Themanshri - avatar