Write a MIN function that determines the minimum of two real numbers.

Write a program using the MIN function to determine the minimum of four real numbers entered on the keyboard.


Difficulty level
Video recording
This exercise is mostly suitable for students
#include <stdio.h>
#include <conio.h>

double MIN(double X, double Y)
{
	return (X<Y) ? X : Y;
}

void main()
{
	double A, B, C, D;

	printf("Enter 4 doubles : ");
	scanf("%lf %lf %lf %lf", &A, &B, &C, &D);
	printf("The minimum is equal to %f \n",
		MIN(MIN(A, B), MIN(C, D)));

	getch();
}

 

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Longest and smallest word in a string