#include<stdio.h>
int main()
{
float x,y;
scanf("%f %f",&x,&y);
if(((int)x%5==0) && (x + .5 <= y))
printf(".2f",y-x-.5);
else
printf(".2f",y);
return 0;
}
#include<stdio.h>
int main()
{
float x,y;
scanf("%f %f",&x,&y);
if(((int)x%5==0) && (x + .5 <= y))
printf(".2f",y-x-.5);
else
printf(".2f",y);
return 0;
}
Please check your output file. You will understand your mistake.
Your approach is right.
in printf function add \n and submit your answer
#include<stdio.h>
int main()
{
int m;
float n,r;
scanf ("%d%f",&m,&n);
if( m%5 ==0 && m < n){
r = n-m-0.5;
printf("%0.2f",r);
}
else
printf("%0.2f",r);
return 0;
}
And, what might this be ??
You do not need to print new line as there is only one input…the error in your code is that you have forgotten to add % in the format specifier of printf function.
The errors with your code is
printf(".2f",y-x-.5);
is supposed to be
printf("%.2f",y-x-.5);
and
printf(".2f",y);
is supposed to be
printf("%.2f",y);
If you do not add the format specifier %
,then printf()
will just output what is inside your double quotes. Well, hope this solves your problem.
please check your program properly … There are some syntax errors.
if u are unable to find them … i will help u then.