Single Choice Not Set

QWhat is the output of this program?

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

ID: #909 Data Types in C Language 2,065 views
Question Info
#909Q ID
Not SetDifficulty
Data Types in C LanguageTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A No
  • B Yes
  • C Compile time error
  • D Run time Error
Correct Answer

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.

Share This Question

Challenge a friend or share with your study group.