Best method to find biggest of 3 numbers

Here is the best implementation to find largest of 3 numbers.

#include<stdio.h>

// Function to find biggest of 2 numbers
int bigger(int num1, int num2)
{
	if(num1 < num2)
		return num2;
	else
		return num1;
}

// Function to find biggest of 3 numbers
int biggest(int num1, int num2, int num3)
{
	return bigger(bigger(num1,num2),num3);
}

int main()
{
	int num1, num2, num3;
	printf("Enter 3 numbers: ");
	scanf("%d %d %d", &num1, &num2, &num3);
	printf("Biggest : %d \n", biggest(num1,num2,num3));
}
VN:F [1.9.17_1161]
Rating: 7.4/10 (12 votes cast)
VN:F [1.9.17_1161]
Rating: +6 (from 8 votes)

05. March 2012 by Jishnu
Categories: C Programming | Tags: | 3 comments

← Older posts

Newer posts →