Question: Question need help finishing this, this is a debugging question... Question need help finishing this, this is a debugging question that only has 1 error

Question need help finishing this, this is a debugging question...

Question need help finishing this, this is a debugging question that only has 1 error in it

The following code defines a function that returns the larger of two inputs passed to the function. There is one problem in this code (Logical, Compile Error, Improvement, Runtime).

Identify the problem and provide the correction in the following format:

  • Line number
  • Type of problem ===> Example: runtime error
  • Problem description ===> Example: 'var' is used before being initialized, error is thrown because 'var' has no value.
  • How to fix ===> Example: initialize 'var' in the constrcutor (var = 0)

Another example of the format is below:

line: ???

type: type of error

Problem: the nature of error or bug

Fix: How to fix it:

Example:

Line: 22

Type: run time error

Problem: deleting uninitialized pointer var.

Fix: set var to nullptr in the constructor

[IMPORTANT] Please note that the line number stated in the answer must correctly point to the problem location. If the line number does not match the problem then answer is invalid. Basically say if line 19 was used in line 19 the problem has to be their.

#include

using namespace std;

template T Max(T a, T b) { return a > b ? a : b; } int main() { int num1 = 10, num2 = 5; double num3 = 10.1, num4 = 10.2; char char1 = 'e', char2 = 102;

cout << "The larger value between " << num1 << " and " << num2 << " is " << Max(num1, num2) << endl; cout << "The larger value between " << num3 << " and " << num4 << " is " << Max(num3, num4) << endl; cout << "The larger value between " << char1 << " and " << char2 << " is " << Max(char1, char2) << endl;

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!