Guest User

Untitled

a guest
Jul 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. // Course: Programming technologies (ANSI C)
  2. // Lab 6. Pointers and Dynamic memory.
  3. // Student: Barabanova E.A. Group: 1513
  4. // Teacher: Alexeev P.S.
  5. // Created 28.12.2009 Modified: 28.12.2009
  6. // Description: Program entry point.
  7. #include <stdio.h>
  8. #include <malloc.h>
  9.  
  10. void main()
  11. {
  12. int a;
  13. float mas[4];
  14. float *pm;
  15. float *pd;
  16. pm = &mas[0];
  17.  
  18. pm[0]='56.4';
  19. pm[1]='36.5';
  20. pm[2]='7.7';
  21. pm[3]='44.3';
  22.  
  23. for (a=0; a<4; a+=1)
  24. {
  25. printf("%f", pm[a]);
  26. };
  27. printf("\n");
  28.  
  29. pd=(float*)calloc(4,sizeof(float));
  30. pd[0]='56.4';
  31. pd[1]='36.5';
  32. pd[2]='7.7';
  33. pd[3]='44.3';
  34.  
  35. for (a=0; a<4; a+=1)
  36. {
  37. printf("%f", pd[a]);
  38. };
  39.  
  40. printf("\n");
  41.  
  42. free(pd);
  43. }
Add Comment
Please, Sign In to add comment