Advertisement
hamaXD

Final 57 struct employee

Dec 5th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. //2 big
  2. #include<stdio.h>
  3.  
  4. struct employee {
  5.     char name[30], surname[50];
  6.     int age;
  7.     float salary;
  8. };
  9. //1.1
  10. struct employee a,b;
  11. //1.2
  12. struct employee a = { "John","Smith",30,20,000 };
  13. struct employee b = { "Miranda","Brook",25,18,000 };
  14. //1.3
  15. #include<string.h>
  16. int main(){
  17.     struct employee c;
  18.     strcpy(c.name,a.name);
  19.     strcpy(c.surname,a.surname);
  20.     c.age=a.age;
  21.     c.salary=a.salary;
  22.  
  23.     strcpy(a.name,b.name);
  24.     strcpy(a.surname,b.surname);
  25.     a.age=b.age;
  26.     a.salary=b.salary;
  27.  
  28.     strcpy(b.name,c.name);
  29.     strcpy(b.surname,c.surname);
  30.     b.age=c.age;
  31.     b.salary=c.salary;
  32.    
  33.     printf("%s %s %d %.3f",a.name,a.surname,a.age,a.salary);
  34.     printf("\n%s %s %d %.3f",b.name,b.surname,b.age,b.salary);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement