# Getting Wrong Ans in this editor,but im getting correct ans in my dev cpp.

#include<stdio.h>

``````int main()
{
float m,n;
int p;
scanf("%d %f",&p,&n);
m=n;
n=n-p;
n=n-0.50;
if(n>50&&p<120&&p%5==0)
{
printf("%.02f",n);
}
else
printf("%.02f",m);
return 0;
}``````

Well you have messed up with your code . Who gave that n>50 and p<120 . In codechef , you will cin values and get input and use those p=120 was just an example you cant assume anything .
I am giving a sample code to you for the problem , any problem contact me
http://ideone.com/AILYqn my code .

Cheers

Firstly correct the format of output statement the specifier should be .2f and not .02f.
Next the condition should be if((p%5==0)&&(n-p-0.5>0))
You should write input statements separately for each input. It has also landed me in trouble many times. If this still gives wrong answer, try inserting “printf(”\n");" at the end of last output statement. Hope this helps…

Your code gives wrong answer for input ` 400 700.05`

Answer should be `299.55` but your code gives `700.05`

Corrected Code:

``````#include<stdio.h>
int main()
{
float m,n;
int p;
scanf("%d %f",&p,&n);
m=n;
//n=n-p;  //this condition is  not required here it is needed later
n=n-0.5;
//if(n>50&&p<120&&p%5==0)	//wrong bound checking, why are you checking for 120 and 50 ?? !!
if((p%5==0)&&(p<=n))
{
n=n-p;
printf("%.2f",n);   //change here  from .02 to .2
}
else
printf("%.2f",m); //change here from .02 to .2
return(0);
}
``````

Your solution modified by me has been accepted, check it here.

thank u everybody i understood.

If your question has been answered or your doubt has been cleared then mark answer(s) which has helped you as accepted. It will help other users to find the correct explanation and also close the question.