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.22_1171]
Rating: 7.8/10 (21 votes cast)
VN:F [1.9.22_1171]
Rating: +3 (from 11 votes)
Best method to find biggest of 3 numbers, 7.8 out of 10 based on 21 ratings

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

Comments (5)

  1. hey jishnu are you doing a course on udacity?

  2. int main()
    {
    int num1, num2, num3, big;
    printf(“Enter 3 numbers: “);
    scanf(“%d %d %d”, &num1, &num2, &num3);
    big = (num3>(num2>num1?num2:num1)?num3:(num2>num1?num2:num1));
    printf(“Biggest : %d \n”, big);
    }

  3. pretty straightforward for the readers, good code snippet

Leave a Reply