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
differentiate built-in functions and user – defined functions.
What is the process to create increment and decrement stamen in c?
What is the purpose of main() function?
What is && in c programming?
Are bit fields portable?
What is the benefit of using #define to declare a constant?
Is c programming hard?
Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?
How can I read in an object file and jump to locations in it?
7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.
What are the types of operators in c?
What is the difference between class and object in c?
What is external variable in c?
Describe the steps to insert data into a singly linked list.
i have a written test for microland please give me test pattern