Write a program to find minimum between three no.s whithout
using comparison operator.
Answers were Sorted based on User's Feedback
Answer / prady
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,temp,Num1,Num2;
printf("Enter 3 no\n");
scanf("%d%d%d",&a,&b,&c);
Num1=a;
Num2=b;
temp=Num1-Num2;
temp&=0x80000000;
temp>>=31;
switch(temp)
{
case -1: Num1=a;
Num2=c;
break;
case 0: Num1=b;
Num2=c;
break;
}
temp=Num1-Num2;
temp>>=31;
switch(temp)
{
case -1: printf("Smallest No is %d\n",Num1);
break;
case 0: printf("Smallest No is %d\n",Num2);
break;
}
getch();
}
| Is This Answer Correct ? | 5 Yes | 0 No |
Answer / ashutosh tiwari
if((a-b)&0x8000)
if((a-c)&0x8000)
printf("a is smaller");
else if((a-c)&0x7fff)
printf("c is smaller");
else
printf("a & c are equal & smaller");
else if((a-b)&0x7fff)
if((b-c)&0x8000)
printf("b is smaller");
else if((b-c)&0x7fff)
printf("c is smaller");
else
printf("b & c are equal & smaller");
else
if((b-c)&0x8000)
printf("b is smaller");
else if((b-c)&0x7fff)
printf("c is smaller");
else
printf("a, b & c are equal & smaller");
| Is This Answer Correct ? | 2 Yes | 1 No |
main() { char ch='356'; Printf("%d",ch); } *OUTPUT*:- -18 *Why?*
How can I prevent other programmers from violating encapsulation by seeing the private parts of my class?
What is the Lvalue and Rvalue?
what is the importance of spanning tree?
What are register variables? What are the advantage of using register variables?
which of 'arrays' or 'pointers' are faster?
c program to compute Income tax and Net Salary for its employees. The company offers tax relief of Kshs. 650 for single employees and Kshs. 1,100 for married employees. The relief will be deducted from the Gross salary, to give the taxable income. This will be computed at the following rates: [10mks] Taxable Income Rate (%) <5000 0 5000-19999 6 20000-36999 9 37000 and above 16
how to determine the complexity of an algorithm as log(n)
IS Doon college of Engn.. has good faculty
Write a program to show the workingof auto variable.
struct tag{ auto int x; static int y; };main() { struct tag s; s.x=4; s.y=5; printf(ā%dā,s.x); }
palindrome for strings and numbers----Can anybody do the prog?
6 Answers CTS, TCS, Vipro Lifescience Pvt,