CSE1002 Salary of Employees (Id-1248)

CSE1002 Salary of Employees (Id-1248)


A company stores the following details of employees such as name, employee id, basic pay, % of DA and HRA. Given details of 'n' employees of an organization, Write an algorithm and a C code to
                          i. get the details of each employee.
                          ii. print their employee id
                          iii. Total salary.
Total salary = Basic Pay + % of DA * basic pay + HRA.

Input Format
value of 'n'
Employee name of employee1
Employee id of employee1
Basic pay of employee1
Percentage of DA of employee1
HRA of employee1
...
Employee name of employee - n
Employee id of employee - n
Basic pay of employee - n
Percentage of DA of employee - n
HRA of employee - n
Output Format
Employee id of employee1
Total salary of employee1
Employee id of employee2
Total salary of employee2
...
Employee id of employee - n
Total salary of employee - n


SOLUTION:
Input:

Number of emloyes(n)

Processing:
    char name[20];
    int i,n,id,bp,da,hra;
    scanf("%d",&n);
    for(i=0;i < n;i++)
    {
        scanf("%s",name);
        scanf("%d%d%d%d",&id,&bp,&da,&hra);
        printf("%d\n%d\n",id,(bp+((bp*da)/100)+hra));
    }


Output:
Display the salaries of all the emploies with ids

Psedocode:
1)Start
2)Read the input
3)Caluclate the salary by using (bp+((bp*da)/100)+hra).
4)Displaythe ID and salary of every employee
5)End

C-CODE:
#include<stdio.h>
void main()
{
    char name[20];
    int i,n,id,bp,da,hra;
    scanf("%d",&n);
    for(i=0;i < n;i++)
    {
        scanf("%s",name);
        scanf("%d%d%d%d",&id,&bp,&da,&hra);
        printf("%d\n%d\n",id,(bp+((bp*da)/100)+hra));
    }

}

Post a Comment

0 Comments