C Program to Calculate Gross Salary of an Employee Using if-else

Gross Salary is the total salary of an employee before deductions. It generally includes Basic Salary, Dearness Allowance (DA), House Rent Allowance (HRA), Travel Allowance (TA) and other applicable benefits.

Gross Salary किसी कर्मचारी का कुल वेतन होता है, जिसमें से कटौतियाँ करने से पहले की राशि शामिल होती है। इसमें सामान्यतः Basic Salary, Dearness Allowance (DA), House Rent Allowance (HRA), Travel Allowance (TA) तथा अन्य लागू भत्ते शामिल होते हैं।

Program

#include <stdio.h>
int main(void)
{
float BS, GS, TA, DA, HRA, Bonus;
printf("Enter basic salary: ");
if (scanf("%f", &BS) != 1 || BS < 0)
{
printf("Invalid basic salary.\n");
return 1;
}
TA = 0.15f * BS;
DA = 0.25f * BS;
HRA = 0.10f * BS;
if (BS >= 25000)
Bonus = 10000;
else if (BS >= 10000)
Bonus = 5000;
else
Bonus = 0;
GS = BS + TA + DA + HRA + Bonus;
printf("\nBasic Salary = %.2f\n", BS);
printf("TA = %.2f\n", TA);
printf("DA = %.2f\n", DA);
printf("HRA = %.2f\n", HRA);
printf("Bonus = %.2f\n", Bonus);
printf("Gross Salary = %.2f\n", GS);
return 0;
}

Output 1

Enter basic salary: 30000
Basic Salary = 30000.00
TA = 4500.00
DA = 7500.00
HRA = 3000.00
Bonus = 10000.00
Gross Salary = 55000.00

Output 2

Enter basic salary: 15000
Basic Salary = 15000.00
TA = 2250.00
DA = 3750.00
HRA = 1500.00
Bonus = 5000.00
Gross Salary = 27500.00

Output 3

Enter basic salary: 8000
Basic Salary = 8000.00
TA = 1200.00
DA = 2000.00
HRA = 800.00
Bonus = 0.00
Gross Salary = 12000.00

Explanation

  1. The program accepts the basic salary from the user.

    प्रोग्राम यूजर से Basic Salary इनपुट के रूप में प्राप्त करता है।

  2. TA is calculated as 15%, DA as 25% and HRA as 10% of the basic salary.

    TA की गणना Basic Salary के 15%, DA की 25% तथा HRA की 10% के रूप में की जाती है।

  3. If the basic salary is greater than or equal to 25000, a bonus of 10000 is added.

    यदि Basic Salary 25000 या उससे अधिक है, तो 10000 का बोनस जोड़ा जाता है।

  4. Otherwise, if the basic salary is greater than or equal to 10000, a bonus of 5000 is added.

    अन्यथा, यदि Basic Salary 10000 या उससे अधिक है, तो 5000 का बोनस जोड़ा जाता है।

  5. If the basic salary is less than 10000, no bonus is added.

    यदि Basic Salary 10000 से कम है, तो कोई बोनस नहीं जोड़ा जाता है।

  6. Finally, the gross salary is calculated by adding Basic Salary, TA, DA, HRA and Bonus.

    अंत में Basic Salary, TA, DA, HRA तथा Bonus को जोड़कर Gross Salary की गणना की जाती है।

Formula

Gross Salary = Basic Salary + TA + DA + HRA + Bonus

The allowance percentages and bonus amounts used in this program are assumed values for educational purposes. Actual salary structures depend on the applicable organization rules.

इस प्रोग्राम में दिए गए भत्तों के प्रतिशत और बोनस की राशि केवल शैक्षणिक उद्देश्य से मानी गई हैं। वास्तविक वेतन संरचना संबंधित संस्था के नियमों पर निर्भर करती है.

Comments

Popular posts from this blog

C Language Topics in Hindi and English

Complete C Programming Syllabus | Advanced C Roadmap for Students

Top High-Paying Tech Skills to Learn in 2025