Program 12 - CSU1128 - CSE 2026 - Shoolini University

Program to calculate the gross salary of employee as per the following norms that if salary is greater than 25000, HRA is 20% of basic pay and DA is 50% of basic pay else HRA is 15% of basic pay and DA is 25% of basic pay.

Explanation

#include <stdio.h> is a preprocessor directive that includes the standard input/output library in the program. This library contains functions such as printf() and scanf() that are used to display output and take input from the user, respectively.

int main() is the main function of the program. It is the entry point of the program, where the execution of the program starts.

In the main function, a floating-point variable d and three more floating-point variables m, j, and o are declared. Then, a prompt is displayed to the user explaining the calculation of the gross salary of an employee based on the given norms.

The program then checks if the basic pay entered by the user is greater than 25000. If it is, the value of the variables m and j are set to 20 and 50, respectively. If the basic pay is less than or equal to 25000, the values of m and j are set to 15 and 25, respectively.

The gross salary of the employee is then calculated by adding the basic pay and the amounts of HRA and DA. The calculated gross salary and the amounts of HRA and DA are then displayed to the user.

Finally, the program returns 0, indicating that the program executed successfully.

The output of the program will look like this:
Program to calculate the gross salary of employee as per the following norms:
 - if salary is greater than 25000, HRA is 20% of basic pay and DA is 50% of basic pay
 - else HRA is 15% of basic pay and DA is 25% ofbasic pay.
Enter the basic pay of the employee - (Example: 23236) - and press enter: 25000
 Gross salary of the employee is 32500.00 with 3750.00 as HRA and 6250.00 as DA amount given to them.

Code

                    
/*
 * -----------------------------------------------------------
 * Logic Building with Computer Programming (CSU1128)
 * Instructor: Dr. Pankaj Vaidya | Author: Divya Mohan
 * 
 * This code is a part of the educational initiative by dmj.one
 * with aim of empowering and inspiring learners in the field of
 * Computer Science and Engineering through the respective courses.
 * 
 * (c) 2022, Divya Mohan for dmj.one. All rights reserved.
 * -----------------------------------------------------------
 */

#include <stdio.h>
int main()
{
    float d, m, j, o;
    printf("\n\n Program to calculate the gross salary of employee as per the following norms:");
    char n[10][10] = {"%"};
    printf("\n\t - if salary is greater than 25000, HRA is 20%s of basic pay and DA is 50%s of basic pay", n[0], n[0]);
    printf("\n\t - else HRA is 15%s of basic pay and DA is 25%s ofbasic pay. \n\n", n[0], n[0]);
    printf("Enter the basic pay of the employee - (Example: 23236) - and press enter: ");
    scanf("%f", &d);
    if (d > 25000)
    {
        m = 20;
        j = 50;
    }
    else
    {
        m = 15;
        j = 25;
    }
    o = d + d * m / 100 + d * j / 100;
    printf("\n Gross salary of the employee is %.2f with %.2f as HRA and %.2f as DA amount given to them. \n", o, d * m / 100, d * j / 100);
    return 0;
}                    
                

Output

Program to calculate the gross salary of employee as per the following norms:
 - if salary is greater than 25000, HRA is 20% of basic pay and DA is 50% of basic pay
 - else HRA is 15% of basic pay and DA is 25% ofbasic pay.

Enter the basic pay of the employee - (Example: 23236) - and press enter: 65334
 Gross salary of the employee is 111067.80 with 13066.80 as HRA and 32667.00 as DA amount given to them.