Question

C -Language Assign to maxSum the max of (numA, numB) PLUS the max of (numY, numZ)....

C -Language Assign to maxSum the max of (numA, numB) PLUS the max of (numY, numZ). Use just one statement. Hint: Call FindMax() twice in an expression.

#include <stdio.h>

double FindMax(double num1, double num2) {
   double maxVal;

   // Note: if-else statements need not be understood to complete this activity
   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;
   double numB;
   double numY;
   double numZ;
   double maxSum;

   scanf("%lf", &numA);
   scanf("%lf", &numB);
   scanf("%lf", &numY);
   scanf("%lf", &numZ);

   /* Your solution goes here */

   printf("maxSum is: %.1f\n", maxSum);

   return 0;
}

Homework Answers

Answer #1
#include <stdio.h>

double FindMax(double num1, double num2) {
    double maxVal;
    // Note: if-else statements need not be understood to complete this activity
    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;
    double numB;
    double numY;
    double numZ;
    double maxSum;

    scanf("%lf", &numA);
    scanf("%lf", &numB);
    scanf("%lf", &numY);
    scanf("%lf", &numZ);

    maxSum = FindMax(numA, numB) + FindMax(numY, numZ);

    printf("maxSum is: %.1f\n", maxSum);

    return 0;
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
What is output? #include <stdio.h> void CheckValue(int* pointVar1, int* pointVar2) {       if (pointVar1 == NULL...
What is output? #include <stdio.h> void CheckValue(int* pointVar1, int* pointVar2) {       if (pointVar1 == NULL && pointVar2 == NULL) {       printf("Pointer is null\n");    }    else if (*pointVar2 > *pointVar1) {       printf("%p\n", *pointVar2);    }    else if (*pointVar1 > *pointVar2) {       printf("%p\n", *pointVar1);    } } int main() {    int num1 = 5;    int num2 = 9;       CheckValue(&num1, &num2);           return 0; } a. 0 b. 5 c. 9 d. Pointer is null e....
C - Language Write an expression that executes the loop while the user enters a number...
C - Language Write an expression that executes the loop while the user enters a number greater than or equal to 0. Note: These activities may test code with different test values. This activity will perform three tests, with user input of 9, 5, 2, -1, then with user input of 0, -17, then with user input of -1. Also note: If the submitted code has an infinite loop, the system will stop running the code after a few seconds,...
All in C language... Write a complete program that declares an integer variable, reads a value...
All in C language... Write a complete program that declares an integer variable, reads a value from the keyboard into that variable, and writes to standard output the variable's value, twice the value, and the square of the value, separated by spaces. Besides the numbers, nothing else should be written to standard output except for spaces separating the values. I got this... and it's wrong #include<stdio.h> int main() { int num; scanf("%d", &num); printf("%d %d %d",num,2*num,num*num); return 0; }
why's is my csis.txt saving ? #include <stdio.h> FILE*fp; void calculateBMI(void); int main(void) {    fp...
why's is my csis.txt saving ? #include <stdio.h> FILE*fp; void calculateBMI(void); int main(void) {    fp = fopen("csis.txt", "w"); for (int i= 0; i<4; ++i){ calculateBMI(); } fclose(fp); return 0; } void calculateBMI(void){ double weight,height,bmi;    printf("Enetr your weight in pounds:\n\n"); fprintf(fp,"Enter your weight in pounds:\n\n"); scanf("%lf",&weight); printf("Enter height in inches:\n\n"); fprintf(fp,"Enter height in inches:\n\n"); scanf("%lf",&height); bmi=(703*weight)/(height*height);    if (bmi<18.5){ printf("You have a BMI of %.lf, and your weight status is underweight\n",bmi);    fprintf(fp,"You have a BMI of %.lf, and...
Question Rewrite the following C program using switch-case statement. and give me an output please use...
Question Rewrite the following C program using switch-case statement. and give me an output please use printf and scanf #include<stdio.h> int main(void) {      int semester;           printf("What is your Studying Level (1-8)?> ");      scanf("%d" , &semester);      if(semester == 1 || semester == 2)           printf("Your are a freshman!\n ");      else if(semester == 3 || semester == 4)           printf("Your are sophomore!\n ");      else if(semester == 5 || semester == 6)           printf("Your are...
#include <stdio.h> int main( void ) {     double height, weight, bmi;     int bmievalcode;    ...
#include <stdio.h> int main( void ) {     double height, weight, bmi;     int bmievalcode;     while( 1 )     {         /* --> add code to input weight and height between here */         scanf("%lf %lf\n" , &weight &height)         bmi = weight * 703 / (height * height);         /* <-- and here */         /* --> add code to calculate bmi and bmievalcode between here */         if (bmi <= 00.0){             bmievalcode = -1;         else...
In C language: Partially finished program is given below. The second and third parameters of the...
In C language: Partially finished program is given below. The second and third parameters of the count() function need to be pointer parameters. However, the programmer forgot to write the necessary ampersands and asterisks in the prototype, call, function header, and function code. Add these characters where needed so that changes made to the parameters adults and teens actually change the underlying variables in the main program. #include #define MAX 10 void count( int ages[], int adults, int teens );...
use c language only to solve this porblem -------------------------- Have the function StringChallenge(str) take the str...
use c language only to solve this porblem -------------------------- Have the function StringChallenge(str) take the str string parameter being passed and return the number of words the string contains (e.g. "Never eat shredded wheat or cake" would return 6). Words will be separated by single spaces. Examples Input: "Hello World" Output: 2 Input: "one 22 three" Output: 3 you have the following code what edits can you do #include <stdio.h> #include <string.h> void StringChallenge(char str[]) {      // code goes...
LANGUAGE C The codes below reads another .c or .txt file. Then, it will read the...
LANGUAGE C The codes below reads another .c or .txt file. Then, it will read the contents of every line and store the contents into a string array. Example: .c file that is to be read: #include <stdio.h> int main(){    printf("Hello World");    return ; } _______________(END OF THE FILE)_______________ Therefore, the code will read the contents above and store the contents in every line into an array, such that.... array[0] = "#include <stdio.h>\n" array[1] = "\n" array[2] ="int...
"C language" Take this code and make the minor modification necessary to create a circular linked...
"C language" Take this code and make the minor modification necessary to create a circular linked list (Hint: Store a pointer to the first node in the next pointer of the last node.) Demonstrate that this is working by traversing the list until the first pointer is encountered 3 times. Next redefine the node structure to include a back pointer. This will enable your program to move from front to back and then from back to front. It is not...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT