Need help (I am a beginner with C)
So I need to create a program where you input 3 integers and the programs will display the largest of the 3. It's not quite working for me, here's what I have so far:
Code:
#include <stdio.h>
main()
{
float a, b, c;
printf("Enter three numbers!\n");
printf("Enter the first number: \n");
scanf("%f" , &a);
printf("Enter the second number: \n");
scanf("%f" , &b);
printf("Enter the third number: \n");
scanf("%f" , &c);
if (a > b , a > c)
{
printf("%f is the largest number!\n" , a);
}
else if (b > a, b > c)
{
printf("%f is the largest number!\n" , b);
}
else
{
printf("%f is the largest number!\n" , c);
}
getch();
return 0;
}
It works when "c" and "a" is the largest number, but when "b" is the largest number, it says "a" is the largest number.
I'm probably making a total noob mistake because I only started C a few days ago. Thanks in advance for the help!
[FONT='Times New Roman', Times, serif]
[/FONT]