Pages

Sunday, 28 January 2018

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.


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.

/* This program takes basic salary from user, calculates dearness and house rent
allowances and then gross salary and shows results.*/
#include<stdio.h>
#include<conio.h>
int main ()
{
    /*declaring veriables*/
    float bsalary, dallow, hrallow, grsalary;
  
    /*prompt to take bsalary as input*/
    printf("Please enter the basic salery: ");
  
    /*taking input*/
    scanf("%f",&bsalary);
  
    /*calculations*/
    dallow = 0.4* bsalary;
    hrallow = 0.2 * bsalary;
    grsalary = bsalary + dallow + hrallow;
 
    /*showing results*/
    printf("\n\nBasic Salary          :          %f Rs\n",bsalary);
    printf("\nDearness Allownce     :          %f Rs \n",dallow);
    printf("\nHouse Rant Allownce   :          %f Rs \n",hrallow);
    printf("___________________________________________\n");
    printf("\nGross Salary          :          %f Rs\n",grsalary);
    getche();
    return 0;
}