Write a program to find minimum between three no.s whithout
using comparison operator.

Answers were Sorted based on User's Feedback



Write a program to find minimum between three no.s whithout using comparison operator...

Answer / rajujadhav22

It is possible with ternary oprator.

Is This Answer Correct ?    27 Yes 2 No

Write a program to find minimum between three no.s whithout using comparison operator...

Answer / sanjeet kumar

with the help of ternary operator

Is This Answer Correct ?    13 Yes 2 No

Write a program to find minimum between three no.s whithout using comparison operator...

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

Write a program to find minimum between three no.s whithout using comparison operator...

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

Post New Answer

More C Interview Questions

How to write a program for swapping two strings without using 3rd variable and without using string functions.

7 Answers   iGate, Infotech,


what are bit fields in c?

0 Answers  


when user give a number it multiply with 9 without useing '+' and '*' oprator

4 Answers  


write a program to print the consecutive repeated character from the given string... input string is : hhhhjkutskkkkkggggj output should be like this: hhhhkkkkkgggg anyone help me...

0 Answers  


Is there any restriction in how many arguments printf or scanf function can take? in which file in my c++ compiler i can see the code for implementation of these two functions??

4 Answers  






will u please send me the placement papers to my mail???????????????????

0 Answers  


Determine the result of performing two successive block transfers into the same area of a frame buffer using the binary arith operations

0 Answers  


What is the mean of this statement:: if(int i=0 * i=9)

2 Answers   HCL,


Write a program that can show the multiplication table.

0 Answers   Student,


Explain what are reserved words?

0 Answers  


What is the difference between ++a and a++?

0 Answers  


What are derived data types in c?

0 Answers  


Categories