Write a program to find minimum between three no.s whithout
using comparison operator.
Answers were Sorted based on User's Feedback
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 |
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 |
How to write a program for swapping two strings without using 3rd variable and without using string functions.
what are bit fields in c?
when user give a number it multiply with 9 without useing '+' and '*' oprator
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...
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??
will u please send me the placement papers to my mail???????????????????
Determine the result of performing two successive block transfers into the same area of a frame buffer using the binary arith operations
What is the mean of this statement:: if(int i=0 * i=9)
Write a program that can show the multiplication table.
Explain what are reserved words?
What is the difference between ++a and a++?
What are derived data types in c?