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.

Expert's answer

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!

LATEST TUTORIALS
APPROVED BY CLIENTS