Write a C program to find the smallest of three integers,
without using any of the comparision operators.
Answer Posted / sachin golechha
Try Doing this way::
main()
{
int a=10,b=7,c=13; /*Assuming a Use Case */
int d; /* d is required a temporary variable */
if((a-b))
{
d = b; /* Which means a was greater than b */
}
else
{
d = a; /* Which means b was greater than a */
}
if((d-c))
{
d = c; /* Which means d was greater than c */
}
else
{
d = d; /* Which means c was greater than d */
}
/* Thus d contains the smallest number of among the 3 */
return SUCCESS;
}
| Is This Answer Correct ? | 22 Yes | 25 No |
Post New Answer View All Answers
a=10;b= 5;c=3;d=3; if(a printf(%d %d %d %d a,b,c,d) else printf("%d %d %d %d a,b,c,d);
When should structures be passed by values or by references?
Write a C program that will accept a hexadecimal number as input and then display a menu that will permit any of the following operations to be carried out: Display the hexadecimal equivalent of the one's complement. (b) Carry out a masking operation and then display the hexadecimal equivalent of the result. (c) Carry out a bit shifting operation and then display the hexadecimal equivalent of the result. (d) Exit. If the masking operation is selected, prompt the user lor the type of operation (bitwise and, bitwise exclusive or, or bitwise or) and then a (hexadecimal) value for the mask. If the bit shifting operation is selected. prompt the user for the type of shift (left or right), and then the number of bits. Test the program with several different (hexadecimal) input values of your own choice.
What is a good data structure to use for storing lines of text?
What are keywords in c with examples?
What is bss in c?
What is the benefit of using an enum rather than a #define constant?
A collection of functions,calls,subroutines or other data a) library b) header files c) set of files d) textfiles
How do you declare a variable that will hold string values?
How to declare a variable?
hi to every one .. how to view table pool after creating the pooled table? plz help me.. if any knows abt this ..
Explain About fork()?
What is line in c preprocessor?
how to execute a program using if else condition and the output should enter number and the number is odd only...
How do you define CONSTANT in C?