Exercise 1:
Ramesh’s basic salary is input through the keyboard. His dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. Write a C program to calculate his gross salary.
Solution:
The output of the program is as follows:
Please enter your Basic Salary = Rs 10000
Therefore the Gross Salary = Rs 16000.00
Ramesh’s basic salary is input through the keyboard. His dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. Write a C program to calculate his gross salary.
Solution:
#include<stdio.h>This is a very simple program, where the basic salary is to inputted from the user and then calculating the DA & HRA and adding them all to get the gross salary. The result is then displayed to the user.
#include<conio.h>
void main()
{
float basic, da, hra, gross; /* Declaration of the variables used in the program */
printf(“Please enter your Basic Salary = Rs ”); /* Printing of the user friendly statement */
scanf(“%f”, &basic); /* Inputting of the basic salary from the user */
da=40*basic/100; /* Calculation of DA */
hra=20*basic/100; /* Calculation of HRA */
gross=basic+da+hra; /* Calculation of Gross Salary */
printf(“\nTherefore the Gross Salary = Rs %.2f”, gross); /* Displaying the result */
getch(); /* Pause the output screen */
}
The output of the program is as follows:
Please enter your Basic Salary = Rs 10000
Therefore the Gross Salary = Rs 16000.00
tnx
ReplyDeleteNice Blog Dude !!!!
ReplyDeleteVisit My Blog For Latest C Programming Exercise
/*guys what about this*/
ReplyDelete#include
void main()
{
float basicsalary,dearnessalowance,houserentalowance,grosssalary;
printf ("\nto calculate the gross_sallary");
scanf("%f\n",&basicsalary);
dearnessalowance=basicsalary*40/100;
printf("%fdearnessalowance\n",dearnessalowance);
houserentalowance=basicsalary*20/100;
printf("%f",houserentalowance);
grosssalary=basicsalary+dearnessalowance+houserentalowance;
printf("\n%fgrosssalary",grosssalary);
}