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
πŸ’¬ Discuss
βœ… Correct Answer: (B) 24
Explanation: 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.
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.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
250
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Kanak Sharma
Publisher
πŸ“ˆ
86%
Success Rate