C Programming – Define stubs for the functions called by the below main().

C Programming

6.3.2: Function stubs: Statistics.

Define stubs for the functions called by the below main(). Each stub should print "FIXME: Finish FunctionName()" followed by a newline, and should return -1. Example output:

FIXME: Finish GetUserNum() FIXME: Finish GetUserNum() FIXME: Finish ComputeAvg() Avg: -1

Answer

  1. #include <stdio.h>
  2. /* GetUserNum Stub*/
  3. int GetUserNum() {
  4. printf("FIXME: Finish GetUserNum() \n");
  5. return -1;
  6. }
  7. /* ComputeAvg Stub*/
  8. int ComputeAvg(int userNum1, int userNum2) {
  9. printf("FIXME: Finish computeAvg() \n");
  10. return -1;
  11. }
  12. int main() {
  13. int usrNum1;
  14. int usrNum2;
  15. int avgResult;
  16. usrNum1 = GetUserNum();
  17. usrNum2 = GetUserNum();
  18. avgResult = ComputeAvg(usrNum1, usrNum2);
  19. printf("Avg: %d\n", avgResult);
  20. return 0;
  21. }

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts