The following is my code for the problem that asks us : Assign to maxSum the max
ID: 3681594 • Letter: T
Question
The following is my code for the problem that asks us :
Assign to maxSum the max of (numA, numB) PLUS the max of (numY, numZ). Use just one statement.
Why am I getting the following error?-/tmp/ccXfSGcm.o: In function `main': main.c:(.text+0xa3): undefined reference to `maxVal' main.c:(.text+0xb9): undefined reference to `maxVal' collect2: ld returned 1 exit status
maxVal is defined in my function
#include <stdio.h>
double FindMax(double num1, double num2) {
double maxVal = 0.0;
if (num1 > num2) { // if num1 is greater than num2,
maxVal = num1; // then num1 is the maxVal.
}
else { // Otherwise,
maxVal = num2; // num2 is the maxVal.
}
return maxVal;
}
int main(void) {
double numA = 5.0;
double numB = 10.0;
double numY = 3.0;
double numZ = 7.0;
double maxSum = 0.0;
maxSum = maxVal(numA,numB) + maxVal(numY,numZ);
printf("maxSum is: %.1f ", maxSum);
return 0;
}
Assign to maxSum the max of (numA, numB) PLUS the max of (numY, numZ). Use just one statement.
Explanation / Answer
Replace statement as below
maxSum = FindMax(numA,numB) + FindMax(numY,numZ);
-->You just not given the method name which you supposed to call.Just that is the cause for the error.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.