18.4k views
0 votes
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

User Bersling
by
4.7k points

2 Answers

3 votes

Final answer:

Stubs are placeholder functions used during initial development of a program. They should print a message and return -1.

Step-by-step explanation:

Stubs are placeholder functions that are used during the initial development stages of a program when the actual implementation of the functions is not yet available. In this case, the stubs for the functions called by the main() function should print the message 'FIXME: Finish FunctionName()' followed by a newline and return -1. Here's an example of the expected output:

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

User Keeganwatkins
by
4.4k points
6 votes

Final answer:

Stubs in programming act as placeholders for functions yet to be fully implemented. The stubs provided for GetUserNum() and ComputeAvg() match the example output, each printing a message indicating they are unfinished and returning -1.

Step-by-step explanation:

In programming, particularly when testing software, stubs are simple implementations of a function used to simulate its behavior. While the final version of the function is not yet developed, stubs provide placeholders that allow the program to compile and run. Below are stubs for two hypothetical functions, GetUserNum and ComputeAvg, which the main program is expected to call.

int GetUserNum() {
printf("FIXME: Finish GetUserNum()\\");
return -1;
}

int ComputeAvg() {
printf("FIXME: Finish ComputeAvg()\\");
return -1;
}

The output of these stubs would align with the example output specified, and each function returns -1 indicating that these are stub implementations awaiting the final logic to be coded.

User BoilingLime
by
4.5k points