+ 1

Below code gives output as 8. How it is possible?

#include <iostream> using namespace std; int main() { int a=010; cout<<a; return 0; } // Output: 8

7th Oct 2017, 4:07 AM
Arjun gowda
Arjun gowda - avatar
6 Antworten
+ 3
@Arjun Gowda The support for 0b was added only after C++03, so if you use an older compiler, 0b may just return an error.
7th Oct 2017, 4:27 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
0
what about this? #include <iostream> using namespace std; int main() { int a=0b111; cout<<a; return 0; } //Output 7
7th Oct 2017, 4:18 AM
Arjun gowda
Arjun gowda - avatar
0
ok what is the prefix for hexadecimal?
7th Oct 2017, 4:23 AM
Arjun gowda
Arjun gowda - avatar