Canna

Sunday, 30 September 2018

payroll using structure

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"
Test Case 1

Input (stdin)

Bogar

1000

15000

Expected Output
Name=Bogar

Id=1000

HRA=1500

DA=3000

Total Salary=19500

#include <stdio.h>
struct employee
{
  char name[100];
  int empid;
  int salary;
  int hra;
  int da;
  float total;
}emp;
int main()
{
  scanf("%s%d%d",emp.name,&emp.empid,&emp.salary);
  printf("Name=%s\n",emp.name);
  printf("Id=%d\n",emp.empid);
  emp.hra=(emp.salary/100)*10;
  printf("HRA=%d\n",emp.hra);
  emp.da=(emp.salary/100)*20;
  printf("DA=%d\n",emp.da);
  printf("Total Salary=%d",emp.salary+emp.hra+emp.da);
 return 0;
}

No comments:

Post a Comment

Note: only a member of this blog may post a comment.