Sunday, June 14, 2020

largest floating point value in c

Three floating point numbers are passed as the input to the program. The program must print the number which has the largest floating point value in it.

Example Input/Output 1:
Input:
12.45 7.89 30.56

Output:
7.89


solution:

int main()

{

float a,b,c;

scanf("%f %f %f",&a,&b,&c);

float m=a-(int)a;

float n=b-(int)b;

float o=c-(int)c;

if(m>n && m>o){

    printf("%.2f",a);

}

else if(n>m && n>o){

    printf("%.2f",b);

}

else{

    printf("%.2f",c);

}


}

No comments:

Post a Comment

MFIB Comma Separated Integers

Fill in the blanks with code so that the program must accept three integers separated by a space and print them separated by a comma as the ...