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


LATEST TUTORIALS
APPROVED BY CLIENTS