189k views
0 votes
Write a program whose inputs are three integers, and whose output is the smallest of the three values.

Ex: If the input is:
7 15 3
the output is:
3

Can someone please help I'm stuck on what to do....

Write a program whose inputs are three integers, and whose output is the smallest-example-1

1 Answer

3 votes

Answer:

#include <stdio.h>

#define MIN(i, j) (((i) < (j)) ? (i) : (j))

int main(void) {

int a,b,c, smallest;

printf("Enter 3 numbers (separated by spaces): ");

scanf("%d %d %d", &a, &b, &c);

smallest = MIN(MIN(a,b), c);

printf("Smallest number is %d.\\", smallest);

return 0;

}

Step-by-step explanation:

This is one way to do it. The MIN macro is a common way to implement an easy to read mechanism to pick the smallest of two values.

User Gurgen Hakobyan
by
5.4k points