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 volatile c?

526


What are identifiers in c?

636


Explain can the sizeof operator be used to tell the size of an array passed to a function?

598


Is multithreading possible in c?

569


hello freinds next week my interview in reliance,nybody has an idea about it intervew questions..so tell

1674






What is wrong in this statement? scanf(ā€œ%dā€,whatnumber);

730


write a programming in c to find the sum of all elements in an array through function.

1709


What is an expression?

659


Is there a built-in function in C that can be used for sorting data?

745


Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?

584


write a c program in such a way that if we enter the today date the output should be next day's date.

1684


Explain what is meant by high-order and low-order bytes?

636


What does the format %10.2 mean when included in a printf statement?

1091


What is a stream water?

659


What is the difference between test design and test case design?

1571