Calculate gross salary

Ramesh’s basic salary is input through the keyboard. His dearness allowance is 35% of basic salary, and house rent allowance is 25% of basic salary. Write a program in C to calculate his gross salary.

Program

#include<stdio.h>
#include<conio.h>
void main()
{
    float bs, da, hra, gs;

	printf("Enter the Basic Salary\t:");
	scanf("%f",&bs);

	da = 35 * bs / 100;
	hra = 25 * bs / 100;
	gs = bs + da + hra;

	printf("\nDearness Allowance     = %f",da);
	printf("\nHouse Rent Allowance   = %f",hra);
	printf("\nGross Salary           = %f",gs);

	getch();
}

Output

Enter the Basic Salary  :25000

Dearness Allowance     = 8750.000000
House Rent Allowance   = 6250.000000
Gross Salary           = 40000.000000

Explanation

In this program, basic salary is taken as an input from the user and stored in variable named 'bs'. For dearness allowance, house rent allowance and gross salary, variables 'da', 'hra' and 'gs' are used respectively.

dearness allowance is 35% of basic salary,
i.e. da = bs * 35 / 100
and house rent allowance is 25% of basic salary,
i.e. hra = bs * 25 / 100
gross salary is sum of all the three things (basic salary, dearness allowance and house rent allowance)
i.e. gs = bs + da+ hra