Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

difference between Low, Middle, High Level languages in c ?

2035


What is the difference between constant pointer and constant variable?

1179


c language interview questions & answer

1914


I need a sort of an approximate strcmp routine?

993


What's the total generic pointer type?

1019


How can I get back to the interactive keyboard if stdin is redirected?

1146


What is function prototype in c language?

992


What are header files in c programming?

1089


I have written a pro*C program to fetch data from the cursor. where in i have used the concept of BULK FETCH.... each FETCH statement is taking lots of time to fetch specified number of rows at...

10157


What is c preprocessor mean?

1256


What standard functions are available to manipulate strings?

1094


can anyone please tell about the nested interrupts?

2076


Explain how can I prevent another program from modifying part of a file that I am modifying?

1046


Whats s or c mean?

963


I need previous papers of CSC.......plz help out by posting them.......

2256