Write a program to find minimum between three no.s whithout
using comparison operator.
Answer Posted / 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 |
Post New Answer View All Answers
What is the use of typedef in c?
Explain which function in c can be used to append a string to another string?
Distinguish between actual and formal arguments.
Explain what is the difference between null and nul?
Which is best book for data structures in c?
Does c have class?
How we can insert comments in a c program?
What are runtime error?
What is the use of pragma in embedded c?
What's the difference between constant char *p and char * constant p?
What is the code for 3 questions and answer check in VisualBasic.Net?
Why string is used in c?
What is file in c preprocessor?
What should malloc() do? Return a null pointer or a pointer to 0 bytes?
List a few unconditional control statement in c.