Question

Assign to maxSum the max of (numA, numB) PLUS the max of (numY, numZ). Use just...

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.
C++ please!

#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;
}

0 0
Add a comment Improve this question Transcribed image text
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;
}
Add a comment
Know the answer?
Add Answer to:
Assign to maxSum the max of (numA, numB) PLUS the max of (numY, numZ). Use just...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In C please Write a function so that the main() code below can be replaced by...

    In C please Write a function so that the main() code below can be replaced by the simpler code that calls function MphAndMinutesToMiles(). Original maino: int main(void) { double milesPerHour, double minutes Traveled; double hours Traveled; double miles Traveled; scanf("%f", &milesPerHour); scanf("%lf", &minutes Traveled); hours Traveled = minutes Traveled / 60.0; miles Traveled = hours Traveled * milesPerHour; printf("Miles: %1f\n", miles Traveled); return 0; 1 #include <stdio.h> 3/* Your solution goes here */ 1 test passed 4 All tests passed...

  • i have no idea how to do floating point comparison this is c programming CHALLENGE 3.16.1:...

    i have no idea how to do floating point comparison this is c programming CHALLENGE 3.16.1: Floating-point comparison: Print Equal or Not equal Write an expression that will cause the following code to print "Equal" if the value of sensorReading is "close enough" to targetValue. Otherwise, print "Not equal". Ex: If targetValue is 0.3333 and sensorReading is (1.0/3.0), output is Equal 1 #include <stdio.h 2 #include <math.h> 4 int main(void)f 6 8 scanf("%lf", &targetValue); 1 test passed double targetValue; double...

  • i'm having trouble making an else statement that will allow the program to add and output...

    i'm having trouble making an else statement that will allow the program to add and output the average the valid numbers inputed into the program. Here's my output: Enter Score 1:36 Enter Score 2:-1 Invalid Input Enter Score 2:89.5 Enter Score 3:42 Enter Score 4:66.3 Enter Score 5:93 You entered: 36.000000, 89.500000, 42.000000, 66.300000, 93.000000 Total Score: 362.800000 Average Score: 72.560000 Max Score: 93.000000 Min Score: 36.000000 Here's my code: #include <stdio.h> int main(void) { double score[5]; double min; double...

  • Write a statement that calls a function named IncreaseItemQty, passing the variable addStock. Assign notebookInfo with...

    Write a statement that calls a function named IncreaseItemQty, passing the variable addStock. Assign notebookInfo with the value returned by IncreaseItemQty. #include <stdio.h> #include <string.h> typedef struct ProductInfo_struct {    char itemName[30];    int itemQty; } ProductInfo; ProductInfo IncreaseItemQty (ProductInfo productToStock, int increaseValue) {    productToStock.itemQty = productToStock.itemQty + increaseValue;    return productToStock; } int main(void) {    ProductInfo notebookInfo;    int addStock = 10;    scanf("%s", notebookInfo.itemName);    scanf("%d", &notebookInfo.itemQty);    /* Your solution goes here */    printf("Name:...

  • CHALLENGE ACTIVITY 5.71 String library functions. Assign the size of userinput to stringSize. Ex: if userinput...

    CHALLENGE ACTIVITY 5.71 String library functions. Assign the size of userinput to stringSize. Ex: if userinput is 'Hello output is: Size of user Input: 5 1 #include <stdio.h> 2 #include <string.h> 4 int main(void) { char user Input[50]; int stringSize; BO scanf("%s", userInput); /* Your solution goes here" printf("Size of user Input: %d\n", stringsize); return ; Run

  • C Programming - RSA encryption Hi there, I'm struggling with writing a C program to encrypt and decrypt a string usi...

    C Programming - RSA encryption Hi there, I'm struggling with writing a C program to encrypt and decrypt a string using the RSA algorithm (C90 language only). It can contain ONLY the following libraries: stdio, stdlib, math and string. I want to use the following function prototypes to try and implement things: /*Check whether a given number is prime or not*/ int checkPrime(int n) /*to find gcd*/ int gcd(int a, int h) void Encrypt(); void Decrypt(); int getPublicKeys(); int getPrivateKeys();...

  • Use only C Program for this problem. Must start with given codes and end with given...

    Use only C Program for this problem. Must start with given codes and end with given code. CHALLENGE ACTIVITY 9.4.3: Input parsing: Reading multiple items. Complete scanf( to read two comma-separated integers from stdin. Assign userlnt1 and userInt2 with the user input. Ex: "Enter two integers separated by a comma: 3,5", program outputs: 3 + 5 = 8 1 #include <stdio.h> HNM 1 test passed int main(void) { int user Int1; int user Int2; All tests passed 000 printf("Enter two...

  • Create another program that will prompt a user for input file. The user will choose from...

    Create another program that will prompt a user for input file. The user will choose from 4 choices: 1. Display all positive balance accounts. 2. Display all negative balance accounts. 3. Display all zero balance accounts. 4. End program. C PROGRAMMING my code so far #include<stdlib.h> #include<stdio.h> int main(void) { int request; int account; FILE *rptr; char name[20]; double balance; FILE *wptr;    int accountNumber;    if((wptr = fopen("clients.dat","w")) == NULL) { puts("File could not be opened"); } else {...

  • How can I integrate these programs into this menu template: #define _CRT_SECURE_NO_WARNINGS #include #include #include #include...

    How can I integrate these programs into this menu template: #define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include void program_one (); void program_two (); void program_three (); void program_four(); void program_five(); int main() { int menu_option = 0; while (menu_option != 9) { printf(" = 1\n"); //Change this to your first program name. Nothing else. printf(" = 2\n"); //Change this to your second program name. Nothing else. printf(" = 3\n"); //Change this to your third program name. Nothing else. printf(" =...

  • Create a functional ATM using the code base given in the example. You must use the...

    Create a functional ATM using the code base given in the example. You must use the routines provided in the code base example. Failure to follow the directions will result in an 'F' the example is down below! /* * @desc: Simple ATM machine * @duedate: 23-April-2019 * * * */ #include <stdio.h> #include <time.h> #include <stdlib.h> #include <string.h> char menu(); char transaction_menu(); /* Verifies the Pin Entered match the PIN on record */ int validatePin(int); /* Verifies the funds...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT