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

How can I sort more data than will fit in memory?

892


write a program to display all prime numbers

1694


why we wont use '&' sing in aceesing the string using scanf

2086


What are the different types of objects used in c?

766


What is the general form of function in c?

808


Here is a neat trick for checking whether two strings are equal

801


What is difference between static and global variable in c?

781


Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

850


Synonymous with pointer array a) character array b) ragged array c) multiple array d) none

831


What is the difference between the = symbol and == symbol?

831


a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f

1855


What is meant by inheritance?

853


Explain the properties of union.

832


What are control structures? What are the different types?

856


What are the types of bitwise operator?

859