Greetings earthlings,
Ok, so I'm trying to write this program in which the user enters in a person's basic salary, and the program calculates the gross salary. Gross salary is the basic salary plus something called a dearness allowance (which is 40% of the basic salary) plus the house rent (which is 20% of the basic salary).
I can enter in the basic salary, but then it will say Ramesh's gross salary is 0.00 rupees. What is the reason it does that? I also don't know what's going on with the getchar() thing. I don't even know what that is. I just know that if I don't put it in, the screen will only pop up for a second and then close.
Code:
#include <stdio.h>
main()
{
float basic_salary, gross_salary, dearness_allowance = .4, house_rent = .2;
gross_salary = (basic_salary+basic_salary*dearness_allowance)+(basic_salary*house_rent);
printf("Please enter Ramesh's basic salary.\n");
scanf("%f", &basic_salary);
getchar();
printf("Ramesh's gross salary is %.2f rupees.\n", gross_salary);
getchar();
}
As always, thanks y'all.