c code

  • cstructure
  • write a code foe company employees in c

    3. Write a structure to store the names, salaries, and hours of work per day of 10 employees in a company. Write a program to increase the salary depending on the number of hours of work per day as follows and then print the name of all the employees along with their final salaries. For Hours of work per day 8, 10, >=12, Increase in salary Rs. 5000, Rs. 10000, Rs. 150000 respectively.

    Code

    #include <stdio.h> typedef struct employee { int time; int salary; char name[50]; } emp; void display(emp *x, int y) { for (int i = 0; i < y; i++) { printf("\n\n"); printf("name: %s\n", x[i].name); printf("time: %d\n", x[i].time); printf("salary: %d\n", x[i].salary); printf("\n\n"); } } void setval(emp *x, int y) { for (int i = 0; i < y; i++) { printf("enter name\n"); scanf("%s", &x[i].name); getchar(); printf("enter time\n"); scanf("%d", &x[i].time); x[i].salary = 2000; } for (int i = 0; i < y; i++) { if (x[i].time > 8 && x[i].time <= 10) { x[i].salary = x[i].salary + 5000; } else if (x[i].time > 10 && x[i].time <= 12) { x[i].salary = x[i].salary + 10000; } else if (x[i].time > 12) { x[i].salary = x[i].salary + 15000; } } } int main() { int n; printf("enter the no. of employee\n"); scanf("%d", &n); emp s1[n]; setval(s1, n); display(s1, n); return 0; }