C Program to Find Maximum of Two Numbers

C Program to Find Maximum of Two Numbers

Write C Program to Find a Maximum of Two Numbers

//WAP to find the maximum of the 2 numbers

#include <stdio.h>

int main()
{
	int n1, n2;

	printf("Enter the number 1 :--> ");
	scanf("%d", &n1);

	printf("Enter the number 2 :--> ");
	scanf("%d", &n2);

	if(n1 > n2)
	{
		printf("\nThe largest number among %d and %d is %d", n1, n2, n1);
	}
	else
	{
		printf("\nThe largest number among %d and %d is %d", n1, n2, n2);
	}

	return 0;
}

Output:

Run 1:
Enter the number1 :--> 89
Enter the number2 :--> 98

The largest number among 89 and 98 is 98


Run 2:
Enter the number1 :--> 98
Enter the number2 :--> 89

The largest number among 98 and 89 is 98