In: Computer Science
Write a program whose inputs are three integers, and whose output is the smallest of the three values. Use else-if selection and comparative operators such as '<=' or '>=' to evaluate the number that is the smallest value. If one or more values are the same and the lowest value your program should be able to report the lowest value correctly. Don't forget to first scanf in the users input.
Ex: If the input is:
7 15 3
the output is:
3
You should sketch out a simple flowchart to help you understand the conditions and the evaluations needed to determine what number is the correct answer. This type of tool can help determine flaws in a logical design.
NOTE: You may use if-else selection and then simplify your answer to use multiple conditions in a simpler else-if selection sequence.
if(some condition) && (some condition) etc. print something else if (some condition) && (some condition) print something else print
#include <stdio.h>
int main(void) {
int num1;
int num2;
int num3;
/* Type your code here. */
//get inputs
/*if(some condition) && (some condition) etc.
print something
else if (some condition) && (some condition)
print something
else
print something
*/
return 0;
}
in c programming
#include<stdio.h>
int main()
{
int num1, num2, num3, small;
printf("Enter three numbers : ");
scanf("%d%d%d", &num1, &num2, &num3);
if(num1<num2)
{
if(num2<num3)
small = num1;
else
{
if(num1<num3)
small = num1;
else
small = num3;
}
}
else
{
if(num2<num3)
small = num2;
else
small = num3;
}
printf("\nSmallest number is: %d", small);
return 0;
}