Program to maintain employee details using structures
Program:
#include<stdio.h>
#include<conio.h>
struct emp
{
int empno;
char name[10];
int bpay, allow, ded, npay;
} e[10];
void main()
{
int i, n;
clrscr();
printf("Enter the number of employees : ");
scanf("%d", &n);
for(i = 0 ; i < n ; i++)
{
printf("\nEnter the employee number : ");
scanf("%d", &e[i].empno);
printf("\nEnter the name : ");
scanf("%s", e[i].name);
printf("\nEnter the basic pay, allowances & deductions : ");
scanf("%d %d %d", &e[i].bpay, &e[i].allow, &e[i].ded);
e[i].npay = e[i].bpay + e[i].allow - e[i].ded;
}
printf("\nEmp. No. Name \t Bpay \t Allow \t Ded \t Npay \n\n");
for(i = 0; i < n; i++)
{
printf("%d \t %s \t %d \t %d \t %d \t %d \n", e[i].empno, e[i].name, e[i].bpay, e[i].allow, e[i].ded, e[i].npay);
}
getch();
}
Output:
Enter the number of employees : 2
Enter the employee number : 101
Enter the name : Arun
Enter the basic pay, allowances & deductions : 5000 1000 250
Enter the employee number : 102
Enter the name : Babu
Enter the basic pay, allowances & deductions : 7000 1500 750
Emp.No. Name Bpay Allow Ded Npay
101 Arun 5000 1000 250 5750
102 Babu 7000 1500 750 7750
-
UpdatedDec 31, 2019
-
Views114,907
You May Like
Program to maintain employee details using structures
Program to maintain student details using structures
Check whether the person is eligible to vote or not
Print the numbers that are divisible by a given no.
Program to generate magic square
To sort the given numbers in ascending & descending order