GET EDUCATE

Contents
Basics of C Programming

⯈Basic C Programs

C program to calculate Gross Salary of an employee

The gross salary of an employee is,

Gross Salary = Basic Salary + DA + HRA.

Given, DA = 64% of Basic salary and HRA = 17% of Basic salary.

The input to the program is basic_salary (double) and output is gross_salary (double). 

Reading the input,

double bs;
scanf("%lf",&bs);

Calculating the gross salary

da = 0.64 * bs;
hra = 0.17 * bs;
gs = bs + da + hra;

C Program

#include<stdio.h>
int main()
{
double bs;
double da, hra, gs;

printf("Enter basic salary:");
scanf("%lf",&bs);

da = 0.64 * bs;
hra = 0.17 * bs;
gs = bs + da + hra;

printf("Gross salary = %lf\n",gs);
return 0;
}

Output Window

output gross salary
Scroll to Top