# Thread: Greater than, less than

1. ## Greater than, less than

Hi everyone:

I have to list three inout numbers in ascending order and here's my code so far:
Code:
```*/
Variables

num1	The first number input by the user
num2	The second number input by the user
num3	The third number input by the user

*/

#include <stdio.h>

int main()

{

float	num1;

float	num2;

float	num3;

float	largest;

float	middle;

float	smallest;

printf("Enter first number\n" );
scanf( "%f" ,  &num1 );

printf("Enter second number\n" );

scanf("%f" , &num2);

printf("Enter the third number\n" );

scanf("%f", &num3 );

if (num1 > num2 )

largest = num1;

printf(The largest number is: %.2f\n, num1);

return 0;
}```
Not perfect yet but my question is this:

Instead of writing a HUGE if statements for all three numbers how can I write something like this:

If num1 > num2 and >num3
then the largest number is num1

Any idea how this is done?
Thank you very much.
-Extro

2. How about putting all your numbers in array and using a loop to find the largest number in the array? Or you could sort the array, from largest to smallest, with the help of a function such as qsort.

3. Originally Posted by Extropian
Instead of writing a HUGE if statements for all three numbers how can I write something like this:

If num1 > num2 and >num3
then the largest number is num1

Any idea how this is done?
Thank you very much.
-Extro
Code:
```if( num1 > num2 && num1 > num3 )
largest = num1;```

4. Code:
`if (num1 > num2 && num1 > num3) largest_number = num1;`