Guest User

Untitled

a guest
Oct 17th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. /* CIS211_2010-01 Lab 1
  2. Instructor: Mr. Sunyata
  3.  
  4. Instructions:
  5.  
  6. 1. Inside of main() initialize pntr_a, pntr_b and pntr_c respectively to
  7. value_a, value_b, and value_c
  8.  
  9. 2. Inside of main() allow the first 3 arguments in the call to function pntr_mix() to be
  10. pntr_a, pntr_b,pntr_c . Add 3 additional arguments to this function call so that the
  11. function call agrees with the function prototype for the function pntr_mix(). Choose
  12. your additional arguments so that your program can provide the values needed for the
  13. printf() statements.
  14.  
  15. 3. make no changes to the printf statements
  16.  
  17. 4.Write the correct code for the function definition for function pntr_mix()
  18. When your code is written correctlly the sums printed in the printf() statements
  19. will have the correct values.
  20. */
  21.  
  22. #include <stdio.h>
  23.  
  24. int pntr_mix(int*,int*,int*,int*,int*,int*) ;
  25.  
  26. int main()
  27. {
  28. int value_a, value_b, value_c ;
  29. int *pntr_a ;
  30. int *pntr_b ;
  31. int *pntr_c ;
  32. int sum_ab, sum_ac, sum_bc , sum_abc ;
  33.  
  34. value_a = 13 ;
  35.  
  36. value_b = 25 ;
  37.  
  38. value_c = 27 ;
  39.  
  40. // **** Initialize the pointers pntr_a, pntr_b, pntr_c : Instruction # 1
  41. pntr_a = &value_a ;
  42. pntr_b = &value_b ;
  43. pntr_c = &value_c ;
  44.  
  45.  
  46. // **** Modify the argument list for this function call : Instruction # 2
  47.  
  48. sum_abc = pntr_mix(pntr_a, pntr_b, pntr_c, &sum_ab, &sum_ac, &sum_bc) ;
  49.  
  50. // **** Make no changes to the following printf() statements : Instruction # 3
  51.  
  52. printf("THE SUM OF A + B IS : %d \n\n" , sum_ab ) ;
  53. printf("THE SUM OF A + C IS : %d \n\n" , sum_ac ) ;
  54. printf("THE SUM OF B + C IS : %d \n\n" , sum_bc ) ;
  55.  
  56. printf("THE SUM OF A + B + C IS : %d \n\n" , sum_abc ) ;
  57.  
  58. printf("END OF PROGRAM EXECUTION: pntr_lab_211() \n\n") ;
  59.  
  60. return 0 ;
  61.  
  62. } // end of function main()
  63.  
  64.  
  65. // **** Write the correct code for the function definition for function pntr_mix()
  66. // **** Instruction # 4
  67.  
  68. int pntr_mix(int* pA,int* pB,int* pC,int* pSum_ab,int* pSum_ac,int* pSum_bc)
  69. {
  70. int result = 0 ;
  71.  
  72. *pSum_ab = *pA + *pB ;
  73. *pSum_ac = *pA + *pC ;
  74. *pSum_bc = *pB + *pC ;
  75.  
  76. result = *pSum_ab + *pSum_ac + *pSum_bc ;
  77.  
  78. return(result) ;
  79.  
  80. } // end of function pntr_mix
Add Comment
Please, Sign In to add comment