Write a C program to calculate 5% DA of a salary
Description: Take the basic salary as input. Calculate 5% DA on it and print the DA and the total salary.
Hint:
- DA = salary x 5 / 100.
C program to calculate the DA of a salary
#include <stdio.h>
int main(void) {
float salary, da, total;
printf("Enter basic salary: ");
scanf("%f", &salary);
da = salary * 5 / 100;
total = salary + da;
printf("DA = %.2f\n", da);
printf("Total salary = %.2f\n", total);
return 0;
}
Output:
Output of the above program is
Enter basic salary: 20000
DA = 1000.00
Total salary = 21000.00
How it works
- 5% of 20000 is
20000 * 5 / 100= 1000. - The total salary is the basic salary plus the DA.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |