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");
}
Answers were Sorted based on User's Feedback
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 |
explain what are actual arguments?
a program that performs some preliminary processing in C, it acts upon certain directives that will affect how the compiler does its work a) compiler b) loader c) directive d) preprocessor
palindrome for strings and numbers----Can anybody do the prog?
6 Answers CTS, TCS, Vipro Lifescience Pvt,
find out largest elemant of diagonalmatrix
wt is diference between int and int pointer as same as float and float pointer and char and char pointer
Is main() is used in the program,,see below example? void main() { int i; for(i=0;i<10;i++) main(); } Then what is the output of the program?
write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?
What does *p++ do?
which one is better structure or union?(other than the space occupied )
Explain logical errors? Compare with syntax errors.
Given an array A[n+m] of n+m numbers, where A[1] ... A[n] is sorted and A[n+1] ... A[n+m] is sorted. Design a linear time algorithm to obtain A[1...n+m] sorted using only O(1) extra space. Time Complexity of your algorithm should be O(n) and Space Complexity O(1).
Why c language is called c?