Open In App

Algorithms Quiz | SP2 Contest 1 | Question 9

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

Article Tags :