Answer to Question #250836 in C for Samzzy

Question #250836
write and test a function called largerof() that replaces the contents of two double variables with the maximum of the two values. for example, largerof(x,y) would reset both x and y to the larger of the two. be sure to test (and include) all the edge cases you can think of to ensure your function works for all double variables.
1
Expert's answer
2021-10-13T20:38:38-0400

Source code

#include <stdio.h>


void largerof(double x,double y){
    if(x>y){
        y=x;
    }
    else{
        x=y;
    }
    printf("\nThe value after:\nx= %0.2f \ny= %0.2f",x,y);
    
}
int main()
{
    double x=23.55;
    double y=56.27;
    printf("The value before:\nx= %0.2f \ny= %0.2f",x,y);
    largerof(x,y);
    
    return 0;
}


Output 1



Output 2


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS