Write a C program to calculate salary raise for employees wh
Write a C program to calculate salary raise for employees which uses the following functions for an array of structures for 7 employees.
If salary is between $ 0 < $ 30000 the rate is 7.0%
If salary is between $ 30000 <= $ 40000 the rate is 5.5%
If salary is greater than $ 40000 the rate is 4.0%
1. Allow the user to enter the data for each employee and for each employee calculate the raise, and the new salary with the raise into an array of structures.
2. Sort the array of structures on name and print the array after the sort is completed.
3. Calculate and print the total Salary, total raises, and total new salary.
4. Save the array of structures to a text file.
5. Retrieve and print the text file.
6. Save the array of structures to a binary file.
7. Retrieve and print the binary file.
Calculation of Salary Raises
| Name | Salary | Rate% | Raise | New Salary | 
| Susan | 25000.00 | 7.00 | 1750.00 | 26750.00 | 
| Jim | 30000.00 | 5.50 | 1650.00 | 31650.00 | 
| Gloria | 35000.00 | 5.50 | 1925.00 | 36925.00 | 
| Ros | 40000.00 | 5.50 | 2200.00 | 42200.00 | 
| Ben | 40001.00 | 4.00 | 1600.04 | 41601.04 | 
| Tim | 45000.00 | 4.00 | 1800.00 | 46800.00 | 
| Total | 215001.00 | 10925.04 | 225926.04 | 
Solution
#include<conio.h>
 #include<stdlib.h>
 #include<stdio.h>
 #include<math.h>
 void inputsalary(float *, float *, float *, float *, float *, float *, float *);
 void print(float c1, float c2, float c3, float c4, float c5, float c6, float c7,
     float ct,
     float d1, float d2, float d3, float d4, float d5, float d6, float d7,
     float dc1, float dc2, float dc3, float dc4, float dc5, float dc6, float dc7,
     float dct,
     float nc1, float nc2, float nc3, float nc4, float nc5, float nc6, float nc7,
     float nct);
      float total7(float c1, float c2, float c3, float c4, float c5, float c6, float c7);
 void rate7(float c1, float c2, float c3, float c4, float c5, float c6, float c7,
     float *, float *, float *, float *, float *, float *, float *);
 void raise7(float c1, float c2, float c3, float c4, float c5, float c6, float c7,
     float d1, float d2, float d3, float d4, float d5, float d6, float d7,
     float *, float *, float *, float *, float *, float *, float *, float *);
 void newsalary7(float c1, float c2, float c3, float c4, float c5, float c6, float c7,
     float dc1, float dc2, float dc3, float dc4, float dc5, float dc6, float dc7,
     float *, float *, float *, float *, float *, float *, float *,
     float *);
 int main()
 {
 float c1, c2, c3, c4, c5, c6, c7;
     float ct;
 float d1=0, d2=0, d3=0, d4=0, d5=0, d6=0, d7=0;
     float dc1=0, dc2=0, dc3=0, dc4=0, dc5=0, dc6=0, dc7=0;
     float dct=0;
     float nc1=0, nc2=0, nc3=0, nc4=0, nc5=0, nc6=0, nc7=0;
     float nct=0;
 inputsalary(&c1, &c2, &c3, &c4, &c5, &c6, &c7);
      st = total7(c1, c2, c3, c4, c5, c6, c7);
      rate7(c1, c2, c3, c4, c5, c6, c7, &d1, &d2, &d3, &d4, &d5, &d6, &d7);
     raise7(c1, c2, c3, c4, c5, c6, c7, d1, d2, d3, d4, d5, d6, d7, &dc1, &dc2, &dc3, &dc4, &dc5, &dc6, &dc7, &dct );
 newsalary7(c1, c2, c3, c4, c5, c6, c7,dc1, dc2, dc3, dc4, dc5, dc6, dc7, &nc1, &nc2, &nc3, &nc4, &nc5, &nc6, &nc7, &nct);
          printf(c1, c2, c3, c4, c5, c6, c7, ct, d1, d2, d3, d4, d5, d6, d7,dc1, dc2, dc3, dc4, dc5, dc6, dc7, dct, nc1, nc2, nc3, nc4, nc5, nc6, nc7,nct );
       system(\"PAUSE\");
     return 0;
 }
 void inputsalary(float *c1, float *c2, float *c3, float *c4, float *c5, float *c6, float *c7)
 {
     printf(\"Enter salary 1:\");
     scanf(\"%f\", &(*c1));
     printf(\"Enter salary 2:\");
     scanf(\"%f\", &(*c2));
     printf(\"Enter salary 3:\");
     scanf(\"%f\", &(*c3));
     printf(\"Enter salary 4:\");
     scanf(\"%f\", &(*c4));
     printf(\"Enter salary 5:\");
     scanf(\"%f\", &(*c5));
     printf(\"Enter salary 6:\");
     scanf(\"%f\", &(*c6));
     printf(\"Enter salary 7:\");
     scanf(\"%f\", &(*c7));
 }
 float total7(float c1, float c2, float c3, float c4, float c5, float c6, float c7)
 {
     return c1 + c2 + c3 + c4 + c5 + c6 + c7;
 }
 void rate7(float c1, float c2, float c3, float c4, float c5, float c6, float c7, float *d1, float *d2, float *d3, float *d4, float *d5, float *d6, float *d7)
 {
      if(c1 < 30000)
     {
         *d1 = 7.0;
     }
     if(c1 >= 30000 && c1 <= 40000)
     {
         *d1 = 5.5;
     }
     if(c1 > 40000)
     {
         *d1 = 4.0;
     }
   
     if(c2 < 30000)
     {
         *d2 = 7.0;
     }
     if(c2 >= 30000 && s2 <= 40000)
     {
         *d2 = 5.5;
     }
     if(c2 > 40000)
     {
         *d2 = 4.0;
     }
     if(c3 < 30000)
     {
         *d3 = 7.0;
     }
     if(c3 >= 30000 && s3 <= 40000)
     {
         *d3 = 5.5;
     }
     if(c3 > 40000)
     {
         *d3 = 4.0;
     }
     if(c4 < 30000)
     {
         *d4 = 7.0;
     }
     if(c4 >= 30000 && c4 <= 40000)
     {
         *d4 = 5.5;
     }
     if(c4 > 40000)
     {
         *d4 = 4.0;
     }
     if(c5 < 30000)
     {
         *d5 = 7.0;
     }
     if(c5 >= 30000 && c5 <= 40000)
     {
         *d5 = 5.5;
     }
     if(c5 > 40000)
     {
         *d5 = 4.0;
     }
     if(c6 < 30000)
     {
         *d6 = 7.0;
     }
     if(c6 >= 30000 && c6 <= 40000)
     {
         *d6 = 5.5;
     }
     if(c6 > 40000)
     {
         *d6 = 4.0;
     }
   
     if(c7 < 30000)
     {
         *d7 = 7.0;
     }
     if(c7 >= 30000 && c7 <= 40000)
     {
         *d7 = 5.5;
     }
     if(c7 > 40000)
     {
         *d7 = 4.0;
     }
 }
 void raise7(float c1, float c2, float c3, float c4, float c5, float c6, float c7,
     float d1, float d2, float d3, float d4, float d5, float d6, float d7,
     float *dc1, float *dc2, float *dc3, float *dc4, float *dc5, float *dc6, float *dc7,
     float *dct)
 {
     *dc1 = c1*d1/(float)100;
     *dc2 = c2*d2/(float)100;
     *dc3 = c3*d3/(float)100;
     *dc4 = c4*d4/(float)100;
     *dc5 = c5*d5/(float)100;
     *dc6 = c6*d6/(float)100;
     *dc7 = c7*d7/(float)100;
     *dct = *dc1 + *dc2 + *dc3 + *dc4 + *dc5+ * dc6 + * dc7;
 }
 void newsalary7(float c1, float c2, float c3, float c4, float c5, float c6, float c7,
     float dc1, float dc2, float dc3, float dc4, float dc5, float dc6, float dc7,
     float *nc1, float *nc2, float *nc3, float *nc4, float *nc5, float *nc6, float *nc7,
     float *nct)
 {
     *nc1 = c1+dc1;
     *nc2 = c2+dc2;
     *nc3 = c3+dc3;
     *nc4 = c4+dc4;
     *nc5 = c5+dc5;
     *nc6 = c6+dc6;
     *nc7 = c7+dc7;
     *nct = *nc1 + *nc2 + *nc3 + *nc4 + *nc5 + *nc6 + *nc7;
 }
 void print(float c1, float c2, float c3, float c4, float c5, float c6, float c7,
     float ct,
     float d1, float d2, float r3, float d4, float d5, float d6, float d7,
     float dc1, float dc2, float dc3, float dc4, float dc5, float dc6, float dc7,
     float dct,
     float nc1, float nc2, float nc3, float nc4, float nc5, float nc6, float nc7,
     float nct)
 {
      printf(\"                        Calculation of Salary Rasies\ \ \");
      printf(\"           Salary       Rate%%       Raise         New Salary         \ \");
     printf(\"                                                                      \ \");
     printf(\"           %0.2f        %0.2f        %0.2f         %0.2f              \ \", c1, d1, dc1, nc1);
     printf(\"           %0.2f        %0.2f        %0.2f         %0.2f              \ \", c2, d2, dc2, nc2);
     printf(\"           %0.2f        %0.2f        %0.2f         %0.2f              \ \", c3, d3, dc3, nc3);
     printf(\"           %0.2f        %0.2f        %0.2f         %0.2f              \ \", c4, d4, dc4, nc4);
     printf(\"           %0.2f        %0.2f        %0.2f         %0.2f              \ \", c5, d5, rc5, nc5);
     printf(\"           %0.2f        %0.2f        %0.2f         %0.2f              \ \", c6, d6, rc6, nc6);
     printf(\"           %0.2f        %0.2f        %0.2f         %0.2f              \ \", c7, d7, rc7, nc7);
     printf(\" Total     %0.2f                     %0.2f         %0.2f              \ \", ct, dct, dct);
 }




