This is an assignment i'm working on:
Write a C program that indicates which of the two given numbers is greater. The program
should receive two float numbers as input from the user. If the first number is greater, the output
should be “The greater number is 1” otherwise the output should be “The greater
number is 2”. Save your program in a file called p3.c. If they are equal, the output should be "The greater number is 1".
Code:
#include <stdio.h>
int main(void)
{
float a, b;
printf("Enter Number 1: ");
scanf("%f", &a);
printf("Enter Number 2: ");
scanf("%f", &b);
if (a > b)
printf("The Greater Number is 1");
else if (a == b)
printf("The Greater Number is 1");
else
printf("The Greater Number is 2");
return 0;
}
Can someone help me out with this? When I run the program I choose two numbers and regardless of the numbers it prints The Greater Number is 1.