Gross Salary (Slab)

Given the basic salary of a person the task is to calculate the gross salary if the company gives Dearness Allowance and Special Allowance as per the given tariff.

BasicDearness Allowance (DA)Special Allowance (SA)
First ₹1 to ₹1000010%5%
Next ₹10001 to ₹2000012%8%
Next ₹20001 to ₹3000015%10%
More than ₹3000020%12%
C
#include <stdio.h>
int main()
{
    double bSalary=0.0,gSalary=0.0,da=0.0,sa=0.0;
    printf("Enter the basic salary: ");
    scanf("%lf",&bSalary);
    if(bSalary<=10000)
    {
        da=0.1*bSalary;
        sa=0.05*bSalary;
        gSalary=bSalary+da+sa;
    }
    else if(bSalary>10000&&bSalary<=20000)
    {
        da= ((10000-0) *0.1)+((bSalary-10000)*0.12);
        sa= ((10000-0) *0.05)+((bSalary-10000)*0.08);
            gSalary=bSalary+da+sa;
    }
    else if(bSalary>20000&&bSalary<=30000)
    {
        da= ((10000-0)*0.1)+((20000-10000)*0.12)+((bSalary-20000)*0.15);
        sa= ((10000-0)*0.05)+((20000-10000)*0.08)+((bSalary-20000)*0.1);
        gSalary=bSalary+da+sa;
    }
    else
    {
        da= ((10000-0)*0.1)+((20000-10000)*0.12)+((30000-20000)*0.15)+((bSalary-30000)*0.2);
        sa= ((10000-0)*0.05)+((20000-10000)*0.08)+((30000-20000)*0.1)+((bSalary-30000)*0.12);
        gSalary=bSalary + da + sa;
    }
    printf ("Dearness Allowance: Rs %lf \n",da);
    printf ("Special Allowance: Rs %lf \n",sa);
    printf ("Gross Salary: Rs %lf \n",gSalary);
    return 0;
}
C