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 c program to find biggest of 3 number without
relational operator?

Answer Posted / kishore kumar naik p

All above answers are wrong.

For "Manjeeth" answer, it does not work always, for example
a= -8, b = 2;
then
res = (int)(a/b)?a:b;
statement says a as big
res = (int)(-8/2)?-8:2;
res = in(-4)?-8:2
res = -8;

which is wrong.

The other two answers are using relational operators so it
does not answer the question. And finally the answer is

void main()
{
int nNum1, nNum2, nNum3;
int nRes,nSize, nBig;
nSize = sizeof(int) * 8;
printf("\nEnter 3 numbers");
scanf("%d%d%d", &nNum1, &nNum2, &nNum3);

nRes = nNum1 - nNum2;
nRes = nRes >> nSize -1;

nBig = nRes ? nNum1 : nNum2;

nRes = nBig - nNum3;
nRes = nRes >> nSize -1;

nBig = nRes ? nBig : nNum3;

printf("big num = %d", nBig);
}

Is This Answer Correct ?    18 Yes 26 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is break statement?

1109


What is malloc return c?

1010


Explain the difference between getch() and getche() in c?

984


What is the hardest programming language?

1130


How do I copy files?

1038


How can I trap or ignore keyboard interrupts like control-c?

1051


Can the size of an array be declared at runtime?

1069


can anyone suggest some site name..where i can get some good data structure puzzles???

2074


What is the explanation for the dangling pointer in c?

1101


Is file a keyword in c?

921


Is it possible to initialize a variable at the time it was declared?

1204


Explain data types & how many data types supported by c?

1070


Why c is faster than c++?

1011


Can we increase size of array in c?

952


please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com

1756