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 the purpose of realloc()?

663


What is multidimensional arrays

624


Do pointers store the address of value or the actual value of a variable?

603


What is the difference between fread buffer() and fwrite buffer()?

665


What is keyword with example?

628






Why void is used in c?

558


Is it possible to pass an entire structure to functions?

548


What is the significance of an algorithm to C programming?

590


Linked list is a Linear or non linear explain if linear how it working as a non linear data structures

1757


Explain two-dimensional array.

621


Why doesn't C support function overloading?

1605


Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?

596


What is the size of array float a(10)?

650


Write a program in c to replace any vowel in a string with z?

683


What does volatile do?

560