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


Please Help Members By Posting Answers For Below Questions

What is the use of typedef in c?

818


Explain which function in c can be used to append a string to another string?

873


Distinguish between actual and formal arguments.

848


Explain what is the difference between null and nul?

923


Which is best book for data structures in c?

850


Does c have class?

893


How we can insert comments in a c program?

884


What are runtime error?

895


What is the use of pragma in embedded c?

826


What's the difference between constant char *p and char * constant p?

935


What is the code for 3 questions and answer check in VisualBasic.Net?

1938


Why string is used in c?

787


What is file in c preprocessor?

927


What should malloc() do? Return a null pointer or a pointer to 0 bytes?

846


List a few unconditional control statement in c.

797