int array[]={1,2,3,4,5,6,7,8};
#define SIZE (sizeof(array)/sizeof(int))
main()
{
if(-1<=SIZE) printf("1");
else printf("2");
}
Answer Posted / c.p.senthil
program prints "2"
Here sizeof returns unsigned int value
so sizeof(array)/sizeof(int)
=> 32(unsigned int)/4(unsigned int)
=> 8 (unsigned int value)
During comparison, the datatypes are different on both sides of if condition
-1(signed int) <= 8(unsigned int)
so by rule of type conversion in c,
signed int gets converted to unsigned int
hence expression becomes
0xFFFFFFFF(unsigned int equivalent of -1) <= 8(unsigned int)
Hence overall condition becomes FALSE
| Is This Answer Correct ? | 72 Yes | 6 No |
Post New Answer View All Answers
What are the general description for loop statement and available loop types in c?
Write a factorial program using C.
pierrot's divisor program using c or c++ code
How is = symbol different from == symbol in c programming?
Discuss the function of conditional operator, size of operator and comma operator with examples.
Explain what are the standard predefined macros?
What is the use of sizeof?
What is use of pointer?
i have to apply for the rbi for the post of officers. i need to know abt the entrance questions whether it may be aps or techinical....
a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none
How many loops are there in c?
Do character constants represent numerical values?
What is return in c programming?
What is break in c?
Write a program to swap two numbers without using the third variable?