C | Data Types | Question 8

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <stdio.h>
int main()
{
    if (sizeof(int) > -1)
        printf("Yes");
    else
        printf("No");
    return 0;
}

chevron_right


(A) Yes
(B) No
(C) Compiler Error
(D) Runtime Error


Answer: (B)

Explanation: In C, when an integer value is compared with an unsigned it, the int is promoted to unsigned. Negative numbers are stored in 2’s complement form and unsigned value of the 2’s complement form is much higher than the sizeof int.

Quiz of this Question



My Personal Notes arrow_drop_up

Improved By : Akanksha_Rai



Article Tags :

1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.