Problem Description
1. Create a Structure "employee"
2. Create six data members for structures as name(char), empid(int), salary(int), hra(int), da(int), total(float)
3. Input the data of the employee as name, empid, salary.
4. Calculate the HRA(10% salary), DA(20% salary)
5. Total pay = salary +hra +da
6. Create structure variable as "emp"CODING ARENA
#include <stdio.h>
struct employee
{
int empid,salary,hra,da;
char name[20];
float total;
}emp;
int main()
{
scanf("%s",emp.name);
scanf("%d",&emp.empid);
scanf("%d",&emp.salary);
emp.hra=emp.salary*0.1;
emp.da=emp.salary*0.2;
printf("Name=%s",emp.name);
printf("\nId=%d",emp.empid);
printf("\nHRA=%d",emp.hra);
printf("\nDA=%d",emp.da);
printf("\nTotal Salary=%.0f",emp.salary+(emp.salary*0.1)+(emp.salary*.2));
return 0;
}
Test Case 1
Input (stdin)Bogar 1000 15000
Expected OutputName=Bogar Id=1000 HRA=1500 DA=3000 Total Salary=19500
Test Case 2
Input (stdin)Agathiyar 1222 20000
Expected OutputName=Agathiyar Id=1222 HRA=2000 DA=4000 Total Salary=26000
No comments:
Post a Comment