Q. Write to calculate the gross salary of an employee of an organization with the conditions: i) if the basic > 25000, DA will be 60%, and house rent is 10% ii) if the basic <= 25000 but >15000, DA will be 65%, and house rent is 15% ii) if the basic <= 15000 , DA will be 70%, and house rent is 2000. [gross salary=basic+DA+house rent]

#include<stdio.h>
main()
{   
    float basic,da,hra,gross;
    printf("\nEnter basic salary=");
    scanf("%f",&basic);
    if(basic>25000)
    {
        da=0.6*basic;
        hra=0.1*basic;
    }
    else if(basic<=25000 && basic>15000)
    {
        da=0.65*basic;
        hra=0.15*basic;
    }
    else
    {
        da=0.7*basic;
        hra=2000;
    }
    gross=basic+da+hra;
    printf("\nDA=%f",da);
    printf("\nHouse rent=%f",hra);
    printf("\nGross salary=%f",gross);
}

No comments:

Post a Comment