+ 5
Why this code will cause an error
#include<iostream> using namespace std; int main() { int a=09; cout<<a; } https://code.sololearn.com/cI4FL3C0Hvv4/?ref=app
4 Answers
+ 5
Because 09 is an invalid octal number,
When add zero in front of a number the compiler looks that number as an octal number,
And an octal number ranges between 0-7 digits
+ 3
ŠŠ³. ŠŠ½Š°Šæš thanks bro
+ 3
I change 012 to 0123 and now it is giving output 83?
Because, it's taken as octal base (8), since that numeral have 0 in leading. So, it's corresponding decimal value is 10.
012 :
(2 * 8 ^ 0) + (1 * 8 ^ 1) = 10
0123 :
(3 * 8 ^ 0) + (2 * 8 ^ 1) + (1 * 8 ^ 2) = 83
+ 3
Now i understand that 0 is for octal