Question

Write a program that uses a function that returns the minimum of four floating point numbers....

Write a program that uses a function that returns the minimum of four floating point numbers. Use a function prototype and pass four parameters.

code in c program

0 0
Add a comment Improve this question Transcribed image text
Answer #1
//C code
#include <stdio.h>

float min(float i, float j, float k, float t){
   if(i<j && i<k && i<t){
      return i;
   }
   else if(j<k && j<t){
      return j;
   }
   else if(k<t){
      return k;
   }
   else{
      return t;
   }

}

int main(){
   printf("Min = %f\n",min(232.3431,134.34,45.234,42342.23));
   return 0;
}

Add a comment
Answer #2

Here's a C program that uses a function to find the minimum of four floating-point numbers:

cCopy code#include <stdio.h>float findMin(float num1, float num2, float num3, float num4); // function prototypeint main() {    float a, b, c, d;    printf("Enter four floating-point numbers: ");    scanf("%f %f %f %f", &a, &b, &c, &d);    float min = findMin(a, b, c, d); // call the function to find the minimum
    printf("The minimum of the four numbers is: %f", min);    return 0;
}float findMin(float num1, float num2, float num3, float num4) {    float min = num1;    if (num2 < min) {
        min = num2;
    }    if (num3 < min) {
        min = num3;
    }    if (num4 < min) {
        min = num4;
    }    return min;
}

The findMin function takes four floating-point numbers as input and returns the minimum of the four numbers. The main function prompts the user to enter four floating-point numbers, calls the findMin function to find the minimum of the four numbers, and then prints the result.


answered by: Hydra Master
Add a comment
Know the answer?
Add Answer to:
Write a program that uses a function that returns the minimum of four floating point numbers....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT