Write a C program to find the smallest of three integers,
without using any of the comparision operators.
Answer Posted / n r sree harsha
#include<stdio.h>
#include<math.h> /* for using abs() function */
main()
{
int a,b,c,small;
printf("\n enter numbers");
scanf("%d%d%d",&a,&b,&c);
if(abs(a-b)-(a-b))
{
if(abs(a-c)-(a-c))
{
s=a;
else
s=c;
}
else
{
if(abs(b-c)-(b-c))
{
s=b;
else
s=c;
}
}
printf("\n small=%d",s);
}
| Is This Answer Correct ? | 0 Yes | 2 No |
Post New Answer View All Answers
What is getch?
Explain how do you convert strings to numbers in c?
How do you determine a file’s attributes?
What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?
Between macros and functions,which is better to use and why?
Write a program to compute the similarity between two strings - The program should get the two strings as input - Then it will output one single number which is the percentage of similarity between the two strings
What are two dimensional arrays alternatively called as?
Write a program to replace n bits from the position p of the bit representation of an inputted character x with the one's complement. Method invertBit takes 3 parameters x as input character, p as position and n as the number of positions from p. Replace n bits from pth position in 8 bit character x. Then return the characters by inverting the bits.
What is the sizeof () operator?
how to construct a simulator keeping the logical boolean gates in c
What is the use of a semicolon (;) at the end of every program statement?
Does c have circular shift operators?
Can you pass an entire structure to functions?
What is 02d in c?
What is a substring in c?