K

Kanak Sharma • 5.38K Points
Tutor III

Q. What will be the output of the following C code?

Code:
#include <stdio.h>

int main()
{
    int a,b,c;
    
    a=0x10; b=010;
    c=a+b;
    
    printf("%d",c);
    
    return 0;
}
  • (A) 20
  • (B) 24
  • (C) Garbage
  • (D) Error

Explanation by: Kanak Sharma
0x10 is hex value it's decimal value is 16 and 010 is an octal value it's decimal value is 8, hence answer will be 24.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.


Question analytics