Ans:-
Program to read the name, address, and salary of 5 employees using array of structure. Display information of each employee and find the average salary on C language.
Program is as follows:--
#include<stdio.h>
#include<string.h>
struct employee
{
char name[10];
char address[50];
int salary;
};
void main()
{
int i, total=0, Avg;
struct employee st[5];
printf("Enter Records of 5 Employees");
for(i=0;i<5;i++)
{
printf("\nEnter Name:");
scanf("%s",st[i].name);
printf("\nEnter Address:");
scanf("%s",st[i].address);
printf("\nEnter Salary");
scanf("%d",&st[i].salary);
total = total + st[i].salary;
}
Avg = total/5;
printf("\n Employee Information List:-");
for(i=0;i<5;i++)
{
printf("\n Name:%s , Address:%s,Salary:%d",st[i].name,st[i].address, st[i].salary);
}
printf("\n Average Salary:%d", Avg);
}
OUTPUT:---
Enter Records of 5 Employees
Enter Name : Vijay
Enter Address : 1B/35
Enter Salay : 2000
Enter Name : tony
Enter Address : 5F/76
Enter Salary : 15000
Enter Name : Sahil
Enter Address : 1C/89
Enter Salary : 45000
Enter Name : Puneet
Enter Address : 4C/32
Enter Salary : 10000
Enter Name : Rishabh
Enter Address : 5C/55
Enter Salary : 13000
Employee Information List:-
Name : Vijay , Address : 1B/35 , Salary : 2000
Name : Tony , Address : 5F/76 , Salary : 15000
Name :Sahil , Address : 1C/89 , Salary : 45000
Name : Puneet , Address : 4C/32 , Salary : 10000
Name : Rishabh , Address : 5C/55 , Salary : 13000
Average Salary : 17000
0 Comments
If you want to give any suggestion regarding the post please feel free to Comment below-