Write a function that calculates the maximum of 2 numbers.


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


int max(int a, int b)
{
	return (a > b) ? a : b;
}

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

 
	printf("Max(%d,%d) = %d\n",a ,b, max(a,b));
 
	getch();
}


Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Series Sum