Exercise 8 - Structures
Exercise 8 - Structures
Exercise 8 Structures
Objective:
The objective of this program is to:
Read the employee details like employee name, date of joining and salary.
And display the total salary of the particular month.
Program Code:
struct personal
{
char name[20];
int day;
char month[10];
int year;
float salary;
};
main()
{
struct personal person [10];
int totalsalary=0;
int n,i;
char month;
printf (“enter number of employees”);
scanf (“%d”,&n);
for (i=1; i<=n; i++)
{
printf("Input Values\n");
scanf("%s %d %s %d %f",
person.name,
&person.day,
person.month,
&person.year,
&person.salary);
printf("%s %d %s %d %f\n",
person.name,
person.day,
person.month,
person.year,
person.salary);
}
Printf(“enter the month for total salary”);
Scanf(“%s”,month)
For(i=1; i<n; i++)
{
t = strcmp(person.month[i], month)
if (t=0)
total salary = total salary + person. salary[i]
}
Printf (“the total salary for giving month = %d”, total salary);
}
Expected Output:
Input Values
Chandu 25 January 2012 5500
Kishore 20 January 2012 5500
Output values
Chandu 25 January 2012 5500.00
Kishore 20 January 2012 5500.00