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...

write a program to compare 2 numbers without using logical
operators?

Answer Posted / faceless

main()
{
int result, sign_bit_num;
unsigned int x, y;

sign_bit_num = sizeof(int)*8 ;

result = x-y;

if (result) {
result = result >> (sign_bit_num-1);

if (result) {
printf("x less than y");
} else {
printf("x greater than y");
}
} else {
printf("equal");
}

Is This Answer Correct ?    14 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is call by reference in functions?

1462


What is mean by data types in c?

1036


any limit on the number of functions that might be present in a C program a) max 35 functions b) max 50 functions c) no limit d) none of the above

1055


How can you be sure that a program follows the ANSI C standard?

1617


What are c preprocessors?

1205


What is typedef struct in c?

1058


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create.

1942


C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions

1065


What is pointer and structure in c?

1193


What is the use of bitwise operator?

1134


How do I get an accurate error status return from system on ms-dos?

1133


what is a constant pointer in C

1187


What is the best organizational structure?

1125


What is a file descriptor in c?

1138


Explain how do you determine whether to use a stream function or a low-level function?

1097