I am trying to write a program that will print the smallest of 3 floating-point numbers using a function. I just learned how to do this function business today... so I'm pretty confused. Can anyone tell me what I did wrong?
Code:
#include <stdio.h>
#include <stdlib.h>
float minimum( float x, float y, float z );
int main( void )
{
float num1, num2, num3;
printf( "Enter 3 numbers.\n" );
scanf( "%.2f%.2f%.2f", &num1, &num2, &num3 );
printf( "Minimum is %.2f\n", minimum( num1, num2, num3 ) );
system("pause");
return 0;
}
float minimum( float x, float y, float z )
{
float min;
if((x < y ) && ( x < z )) {
min = x;
}
if((y < x ) && ( y < z )) {
min = y;
}
if((z < x ) && ( z < y )) {
min = z;
}
return min;
}