Write a function that calculates the minimum of 2 numbers.


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


int min(int a, int b)
{
	return (a < b) ? a : b;
}

void main()
{
	int a, b;
	printf("Enter two integers: ");
	scanf("%d%d", &a, &b);

 
	printf("Min(%d,%d) = %d\n",a ,b, min(a,b));
 
	getch();
}


Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Maximum sum in sliding window