Advertisement
Aminpro

[ECP 1016]Tutorial 10, Question 1(All)

Sep 2nd, 2012
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. //https://www.facebook.com/AminproPastebin
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. struct staff{
  7. char name[10];
  8. int id;
  9. float allowance;
  10.  
  11. };
  12.  
  13. int main(void){
  14. struct staff oc1, *ocPtr;
  15.  
  16. strcpy(oc1.name, "Ahmed");
  17. oc1.id = 1081112345;
  18. oc1.allowance = 135.8;
  19.  
  20. struct staff oc2 = {"Patrick", 1071198763, 264.20};
  21.  
  22. printf("Total = %.2f; Average = %.2f", oc1.allowance + oc2.allowance, ((oc1.allowance + oc2.allowance)/2));
  23.  
  24. ocPtr = &oc1;
  25.  
  26. ocPtr -> id = 1071112345; //or using (*ocPtr).id = 1071112345 //Page 209
  27.  
  28. return 0;
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement