Hello I am trying to write a program and the objective is to have the user enter in 3 numbers and then have the computer tell us which is the bigger number. Whenever I use this code it will take the numbers in but it won't tell me which one is bigger and I can't find the mistake.
int main ()
float n1, n2, n3;
printf("Enter 3 coefficients a, b, c:");
scanf("%f %f %f", &n1, &n2, &n3);
printf("%f is the maximum\n", n1); //Okay
printf("%f is the maximum\n", n3); //Not true, how do you know: n3 > n2
elseif (n2>n1) //not really needed
printf("%f is the maximum\n", n2); //Okay
You don't need else if in this program. Go back over the logic. Do this yourself a few time on paper, then try to model what your brain is thinking in C++.
Also, indent your code so you can follow the logic better. And, possibly consider using >= or <= in some places, instead of just > or <.