#include<stdio.h>
int main()
{int x;
float y;
scanf("%d",&x);
scanf("f",&y);
if(x>=y)
printf(".2f",y);
else
{
if(x%5==0)
{y=y-(float)x-0.50;
printf("%.2f",y);}
else
printf("%f",y);
}
}
Please post a link to your solution and to the question as well. Nobody can understand your code this way.
Edit: I have resubmitted your code by adding return 0 at the end of the main function. The answer is still wrong. I hope you can find the reason on your own
http://www.codechef.com/viewsolution/6774066
First of all, please provide a proper solution link and a link to the problem.
Secondly, you have made a lot of mistakes in your code.
-
Put \n when printing the result
-
When comparing int with a floating point number use typecasting as shown in the code below
-
x can be 0 as well. At such point, the bank should not deduct any money. In your code the bank is still deducting 0.50$
-
Also, when x is divisible by 5, you have to check whether x+0.50 is greater than y or not.
#include< stdio.h>
int main()
{
int x;
float y;
scanf("%d",&x);
scanf("%f",&y);
if((float)x>=y)
printf("%.2f\n",y);
else if(x==0)
printf("%.2f\n",y);
else
{
if(x%5==0)
{
if(y>(float)x+0.50)
y=y-(float)x-0.50;
printf("%.2f\n",y);
}
else
printf("%.2f\n",y);
}
}