Sail E0 Webinar
Question


What is the output of the following program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int num = 0x20 + 020 + 20;
6.
cout
Options:
A .  2
B .  4
C .  Depends on compiler.
D .  garbage
Answer: Option C

The sum of three numbers are belongs to different number systems, so the result is typecasted into integer.
Output:
$ g++ size.cpp
$ a.out
4



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers