Advertisement
Salman_CUET_18

Soikot

Jul 26th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.00 KB | None | 0 0
  1. #include<stdio.h>
  2. struct Employee
  3. {
  4.     int Eno;//Eno for employee number
  5.     char name[20];
  6.     float salary;
  7.     char DOJ[20]; //DOJ for date of join
  8. };
  9. int main(void)
  10. {
  11.     struct Employee employees[5];
  12.     for(int i = 0; i < 5; i++)
  13.     {
  14.         printf("Enter the name of the employee for employee no %d: ", i + 1);
  15.        gets(employees[i].name);
  16.         printf("Enter the salary: ");
  17.         scanf("%f", &employees[i].salary);
  18.         getchar();//to ignore the '\n' which you enter after entering the salary
  19.         // '\n' may assign in the next string call so we have to ignore it
  20.         printf("Enter the date of join: ");
  21.         gets(employees[i].DOJ);
  22.     }
  23.     for(int i = 0; i < 5; i++)
  24.     {
  25.         if(employees[i].salary > 20000)
  26.         {
  27.             printf("Employee No: %d\n", i + 1);
  28.             printf("Name: %s\n", employees[i].name);
  29.             printf("Salary: %f\n", employees[i].salary);
  30.             printf("DOJ: %s\n", employees[i].DOJ);
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement