Q: Ramesh’s basic salary is input through the keyboard. His dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. Write a program to calculate his gross salary.

#include<stdio.h>
int main()
{
float bs, da, hr, gs;      /*bs=basic salary,da=dearness allow,hr=house rent, gs=gross salary*/
    printf("Enter Basic Salary: ");   
    scanf("%f",&bs);

    da = 0.4 * bs;
    hr = 0.2 * bs;
gs= bs + da + hr;

        printf("\nBasic Salary: %f\n",  bs);
    printf("Dearness Allowance: %f\n", da);
    printf("House Rent: %f\n", hr);
    printf("\n\nGross Salary: %f\n",gs);

    return 0;
}

-----------------------------------------
Output:

Enter Basic Salary: 1000

Basic Salary: 1000.000000
Dearness Allowance: 400.000000
House Rent: 200.000000


Gross Salary: 1600.000000

Comments

Popular posts from this blog

Q: The length & breadth of a rectangle and radius of a circle are input through the keyboard. Write a program to calculate area & perimeter of the rectangle and area & circumference of the circle.

Q: If a five-digit number is input through the keyboard, write a program to calculate the sum of its digits. (Hint: Use the modulus operator ‘%’)