+ 1
what is is output int var=010; printf("%d",var); who explain
3 Answers
+ 2
010 is not the same as 10. Due to the 0 placed at the beginning the number will be interpreted as an octal (base 8) instead of the standard decimal (base 10). Where each place can hold a value from 0-7. The farthest place to the right (the ones place) has a value of zero. 0 * 1 = 0. The next place to the left of that is increased times eight and holds a value of 1. 1 * 8 = 8. Then add the places together to get the result of 8.
As you move to the left each place will increase exponentially by 8^n.
https://www.tutorialspoint.com/octal-number-system
+ 2
8 is correct as it is something in octal number , there different numbering systems, like binary(base 2) ,octal(base 8), decimal(base 10), and hexadecimal(base 16)
These base represents total number of basic numbers they can have , these are calculated as summation((base^n) An) here An means value of nth digit from right to left..........
In this case A1=0,A2=1,A3=0, base=8
Result =(8^0*0)+(8^1*1)+(8^2*0)
=0+8+0
=8
+ 2
8 is correct as it is something in octal number , there different numbering systems, like binary(base 2) ,octal(base 8), decimal(base 10), and hexadecimal(base 16)
These base represents total number of basic numbers they can have , these are calculated as summation((base^n) An) here An means value of nth digit from right to left..........
In this case A1=0,A2=1,A3=0, base=8
Result =(8^0*0)+(8^1*1)+(8^2*0)
=0+8+0
=8



