#include <iostream> using namespace std; int main() { int num = 0x20 + 020 + 20; cout << sizeof(num)<<'\n'; return 0; }
a) 2
b) 4
c) Depends on compiler
d) Garbage
#include <iostream> using namespace std; int main() { int num = 0x20 + 020 + 20; cout << sizeof(num)<<'\n'; return 0; }
a) 2
b) 4
c) Depends on compiler
d) Garbage
You must be logged in to post a comment.
d
Explanation: The a as a integer will be converted to float while calculating the size. The value of any variable doesn’t modify inside sizeof operator. Hence value of variable a will remain 5.
Output:
$ g++ size3.cpp
$ a.out
4 5