Monday, February 15, 2016

C Program to calculate gross salary

/*=================================================================================
**
**  File Name     : grossSalary.c
**  Creation Date : Mon 15 Feb 2016 03:33:41 AM IST
**  Last Modified : Mon 15 Feb 2016 04:02:41 AM IST
**  Compoler      : gcc
**  Author        : Manoj Kumar Patra, manojpatra.in@gmail.com
**  Organization  : SCIS, University of Hyderabad, India.
**
**===============================================================================*/

#include<stdio.h>
int main()
{
    printf("\n= = = = = = = = = = Calculation of Gross Salary = = = = = = = = = =\n");
    int bs;
    float hra, da, gs;
    printf("\nEnter the Basic Salary(must be a +ve integer): ");
    scanf("%d",&bs);
    if(bs >=1 && bs<=1000)
    {
        hra = (10*bs)/100;
        da = (50*bs)/100;
        printf("\nThe House Rent Allowance is 10 percent of %d = %f\n",bs,hra);
        printf("\nThe Dearness Allowance is 50 percent of %d = %f\n",bs,da);
    }
    else if(bs >=1001 && bs<=2000)
    {
        hra = (20*bs)/100;
        da = (60*bs)/100;
        printf("\nThe House Rent Allowance is 20 percent of %d = %f\n",bs,hra);
        printf("\nThe Dearness Allowance is 60 percent of %d = %f\n",bs,da);
    }
    else if(bs >=2001 && bs<=3000)
    {
        hra = (25*bs)/100;
        da = (70*bs)/100;
        printf("\nThe House Rent Allowance is 25 percent of %d = %f\n",bs,hra);
        printf("\nThe Dearness Allowance is 70 percent of %d = %f\n",bs,da);
    }
    else
    {
        hra = (30*bs)/100;
        da = (80*bs)/100;
        printf("\nThe House Rent Allowance is 30 percent of %d = %f\n",bs,hra);
        printf("\nThe Dearness Allowance is 80 percent of %d = %f\n",bs,da);
    }
    gs = bs + hra + da;
    printf("\nThe Gross Salary of %d is: %f\n",bs,gs);
    printf("\n= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n\n");
}

Output:

= = = = = = = = = = Calculation of Gross Salary = = = = = = = = = =

Enter the Basic Salary(must be a +ve integer): 13400

The House Rent Allowance is 30 percent of 13400 = 4020.000000

The Dearness Allowance is 80 percent of 13400 = 10720.000000

The Gross Salary of 13400 is: 28140.000000

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

No comments:

Post a Comment