Answer to Question #208878 in C for Prasanna

Question #208878

Write a function named Smallest that takes three integer inputs and returns an integer that is the smallest of the three inputs. Write the prototype for the smallest function. Write a program that gets 3 integers from a user and displays the smallest.


Input :

5

6

8


Output :

5


1
Expert's answer
2021-06-21T12:50:15-0400
#include <stdio.h>


int Smallest(int x1, int x2, int x3);


int main()
{
    int a, b, c, d;


    printf("Insert first value: ");
    scanf("%d", &a);
    printf("Insert second value: ");
    scanf("%d", &b);
    printf("Insert third value: ");
    scanf("%d", &c);
    d =  Smallest(a, b, c);


    printf("The smallest value is %d\n", d);


    return 0;
}


int Smallest(int x1, int x2, int x3) {
    if (x1 <= x2 && x1 <= x3) {
        return x1;
    }
    if (x2 <= x1 && x2 <= x3) {
        return x2;
    }
    return x3;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS