Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Each of the following functions has errors. Locate as many errors as you can. A) void total(int valuel, value?, value3) B) double average(tnt valuel, tht value2, int value3) C) vold area (int length \(=30\), int width) D) void getValue( 1 nt values) E) \(1 /\) Overloaded functions

Short Answer

Expert verified
, value3) B) double average(tnt valuel, tht value2, int value3) C) vold area (int length \(=30\), int width) D) void getValue(1 nt values) E) (1/) Overloaded functions Answer: A) void total(int value1, int value2, int value3) B) double average(int value1, int value2, int value3) C) void area(int length = 30, int width) D) void getValue(int values) E) // 1. Overloaded functions

Step by step solution

01

A) void total(int valuel, value?, value3)

The given function has the following errors: 1. Incorrect variable name 'value?'. Variable names should contain only letters, digits or underscores. 2. Missing data type for the parameter 'value?'. To correct the function, change the function signature as follows: ```cpp void total(int value1, int value2, int value3) ```
02

B) double average(tnt valuel, tht value2, int value3)

The given function has the following errors: 1. Incorrect data types 'tnt' and 'tht'. They should be 'int'. 2. Incorrect variable name 'valuel'. Use 'value1' instead. To correct the function, change the function signature as follows: ```cpp double average(int value1, int value2, int value3) ```
03

C) vold area (int length \(=30\), int width)

The given function has the following errors: 1. Incorrect return type 'vold'. It should be 'void'. 2. The equal sign '\(=\)' should be replaced with the assignment operator '=' for the default value assignment for the parameter 'length'. 3. The variable name 'width' in the parameter list should be changed to a valid name that follows C++ naming conventions. To correct the function, change the function signature as follows: ```cpp void area(int length = 30, int width) ```
04

D) void getValue( 1 nt values)

The given function has the following errors: 1. Incorrect data type 'nt' should be changed to 'int'. 2. Incorrect parameter name '1 nt values'. The parameter name should follow C++ naming conventions. To correct the function, change the function signature as follows: ```cpp void getValue(int values) ```
05

E) \(1 /\) Overloaded functions

This line seems to be an instruction or comment unrelated to the code. If this is the case, then it should be written as a comment using '//' in C++. To correct this line, change it as follows: ```cpp // 1. Overloaded functions ```

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Study anywhere. Anytime. Across all devices.

Sign-up for free