Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

name an error present in the following pseudocode. start declarations g…

Question

name an error present in the following pseudocode. start declarations global num merchcost output \enter purchase total: \ input merchcost calculatesalestax() output \please pay \, (merchcost + salestax) stop calculatesalestax() declarations num salestax num taxrate = .08 salestax = taxrate * merchcost return a. the main program declares only global variables. b. the module attempts to use a variable that is out of scope. c. the main program attempts to use a variable that is out of scope. d. the module is never called by the main program.

Explanation:

Brief Explanations

The salesTax variable is declared and calculated within the calculateSalesTax() module. In the main program, when trying to use salesTax in the output statement output "Please pay ", (merchCost + salesTax), the variable salesTax is out - of - scope as it is a local variable to the calculateSalesTax() module and not properly passed back or declared globally in a way that the main program can access it.

Answer:

c. The main program attempts to use a variable that is out of scope.