Printf MCQ 22 : sizeof (octal + hexadecimal + integer )
Printf Multiple Choice Questions 21 : Sum of three Different Numbers
Predict the Output of the Following Program if Given Things are -
#include<stdio.h> void main() { int num1 = 0x20 + 020 + 20; printf("%d",sizeof(num1)); }
Options :
- 2
- 4
- 30
- Garbage
[toggle title=”Output”]2[/toggle]
How and Why ?
- Sum of Three numbers belonging to Different number system is assigned to Variable ‘num1’ which is of integer Type
- So result is Typecasted into Integer
- Size of Integer is 2 bytes