Skip to content
Related Articles

Related Articles

Improve Article
Algorithms Quiz | SP2 Contest 1 | Question 9
  • Last Updated : 28 Aug, 2018

What will be the output of the below C program?




#include <stdio.h>
int main()
{
    if (sizeof(int) > -10)
        printf("YES");
    else
        printf("NO");
    return 0;
}

(A) YES
(B) NO
(C) YESNO
(D) Compilation Error


Answer: (B)

Explanation: In C, when an integer value is compared with an unsigned int, 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
Please comment below if you find anything wrong in the above post

My Personal Notes arrow_drop_up
Recommended Articles
Page :