Friday, October 1, 2010

Simple if else ladder program in C language

Write a program to calculate gross salary for the conditions given below.
BASIC SALARY(Rs) DA(Rs) HRA(Rs) CONVEYANCE(Rs)
----------------------- ----------------- ---------------- ----------------------
BS>=5000 110% of Basic 20% of Basic 500
BS>3000 &&
BS<5000 100% of Basic 15% of Basic 400
BS<3000 90% of Basic 10% of Basic 300


int main()
{
float bs,gs;
printf("Enter basic salary");
scanf("%f",&bs);

if(bs>=5000.0)
{
gs=bs+500.0+(.110*bs)+(.20*bs);
}else if(bs>=3000)
{
gs=bs+400.0+(0.1*bs)+(0.15*bs);
}
else
{
gs=bs+300.0+(0.90*bs)+(0.10*bs);
}
printf("Gross Salary=Rs%.2f",gs);
getch();
}

No comments:

Post a Comment

Google+ Followers