Devise a function my_min(x,y) that returns the smaller of two float values, and test the function with a driver. The driver should prompt the user for input and then display the value returned by the my_min() function.
Notes:
I am asking you to call the function my_min() instead of just min() to avoid any possible conflict with the min() function included with your C compiler, usually in stdlib.h.
This is what I have so far
Code:
#include "stdafx.h"
float my_min(float a, float b);
int _tmain(int argc, _TCHAR* argv[])
{
float a,b;
int x= 12.345;
int y= 67.78;
printf("Enter a value for x\n");
scanf("%f", &a);
printf("Enter a value for y\n");
scanf("%f", &b);
printf("The smaller of %f and %f is %f.\n", a, b, my_min(x,y));
return 0;
}
When working with float values so it should be:
float my_min(float a, float b);
and inside main() we use the variables x and y but inside my_min() we use a and b.
I have created a function prototype which tells the compiler how to call the function, but I have not created the function.
How do I do that
Feedback and help would be greatly appreciated.