Open In App

Algorithms Quiz | SP2 Contest 1 | Question 9

Like Article
Like
Save
Share
Report

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


Last Updated : 28 Aug, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads