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

Explain how many levels deep can include files be nested?

0 Answers  


What does 1f stand for?

0 Answers  


What are the different types of constants?

0 Answers  


write a program that eliminates the value of mathematical constant e by using the formula e=1+1/1!+1/2!+1/3!+

1 Answers   Reliance,


#include<stdio.h> main() { int a[3]; int *I; a[0]=100;a[1]=200;a[2]=300; I=a; Printf(“%d\n”, ++*I); Printf(“%d\n”, *++I); Printf(“%d\n”, (*I)--); Printf(“%d\n”, *I); } what is the o/p a. 101,200,200,199 b. 200,201,201,100 c. 101,200,199,199 d. 200,300

4 Answers   Tieto,






What will be result of the following program? void myalloc(char *x, int n) { x= (char *)malloc(n*sizeof(char)); memset(x,\0,n*sizeof(char)); } main() { char *g="String"; myalloc(g,20); strcpy(g,"Oldstring"); printf("The string is %s",g); } a) The string is : String b) Run time error/Core dump c) The string is : Oldstring d) Syntax error during compilation e) None of these

3 Answers   IBM,


A C E G H +B D F A I ------------ E F G H D

1 Answers   Infosys,


Explain modulus operator.

0 Answers  


what will be the output: main(){char ch;int a=10;printf("%d",ch);}

36 Answers   Accenture, TCS, Wipro,


what is the function of void main()?

8 Answers  


how to make program without <> in library.

1 Answers   ADITI,


What are valid signatures for the Main function?

0 Answers  


Categories