+1

# Please explain comparison of negative number

#include <stdio.h> int main(){ int a=10, b =13, d=13, k=-1, c; c= sizeof(long double) < -3-k || b==d && b<a; printf("%d", c); return 0; }

7/4/2022 5:35:31 AM

Akshay Bhujbal

+4

The code is only evaluating 'sizeof(long double) < -3-k' this returns true, or 1. The rest is ignored because there is no need to check because of how '||' works. sizeof returns an unsigned number so -3-k has to be converted to an unsigned number as well. Since -3-k is a negative number the resulting non-negative number is a very big number and the size of a long double is of course less than that big number.

+2

Negative values, and any non-zero values in general, are treated as true when used as conditions C= size(long double) < (-3-k || b==d && b<a); ->&& operator return true if both condition are true Hence b<a is false -> || condition return true if one of statement is true -3-k is negative and non zero number so it is treated true True ->1

+2

Compare that with sizeof(long double )

+2

Akshay, What are you trying to calculate here?

+2

Akshay Bhujbal sizeof(long double) = 16 16<1 :: false.. So answer is zero you put ques like in bracket

+2

Answer is 1 you can run it

+2

Akshay Bhujbal ya but without bracket you can check it .. Further now you got the output..

+2

Okay, thank you for the explanation

+1

The question was find the output

+1

Question was not asked with bracket