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 would you find a cycle in a linked list?

3 Answers   NSN,


what is the difference between char * const and const char *?

2 Answers   TCS,


program to find a smallest number in an array

15 Answers   Microsoft, Sony,


enum DAY { sunday, monday, tuesday }; enum EDAYS { friday, saturday, sunday }; void main() { int i =0; if( i == sunday) { printf("%d",i); } } what would be the output?

4 Answers   TCS,


can please someone teach me how to create this program using while statement.. this is the output should look like 0 2 4 6 8 10 -thanks.. :) need it asap...

7 Answers  


Explain how can you avoid including a header more than once?

0 Answers  


What is the best way of making my program efficient?

0 Answers  


Is it acceptable to declare/define a variable in a c header?

0 Answers  


a number whose only prime factors are 2,3,5, and 7 is call humble number,,write a program to find and display the nth element in this sequence.. sample input : 2,3,4,11,12,13, and 100.. sample output : the 2nd humble number is 2,the 3rd humble number is 3,the 4th humble number is ,the 11th humble number is 12, the 12th humble number is 14, the 13th humble number is 15, the 100th humble number is 450.

0 Answers  


What is page thrashing?

0 Answers  


What is the purpose of Scanf Print, getchar, putchar, function?

3 Answers  


Describe advantages and disadvantages of the various stock sorting algorithms

1 Answers   Microsoft,


Categories