#include <stdio.h>
int main()
{
int wd;
float c;
scanf("%d%f",&wd,&c);
if((wd%5)==0 && .5 <=c-(float)wd)
{c=c-wd-0.5;}
printf("%.2f",c);
}
Why isn’t it working and showing runtime error
#include <stdio.h>
int main()
{
int wd;
float c;
scanf("%d%f",&wd,&c);
if((wd%5)==0 && .5 <=c-(float)wd)
{c=c-wd-0.5;}
printf("%.2f",c);
}
Why isn’t it working and showing runtime error
Hey brother about RE it is because your code is not returning 0 so just add return 0.
Added ‘\n’ but there is no need to do so for this problem, but still it is a good practice to use ‘\n’.
I corrected those mistakes and here is the AC version of your code:
#include <stdio.h>
int main()
{
int wd;
float c;
scanf("%d%f",&wd,&c);
if((wd%5)==0 && .5 <=c-(float)wd)
{c=c-wd-0.5;}
printf("%.2f\n",c);
return 0;
}
Or you may check same code in this AC’ed Submision:
http://www.codechef.com/viewsolution/5678028
Welcome to Codechef…
I don’t think \n is needed. But you need to explicitly return 0 in case of C programming language.
FYI: only main() is the special function in C++ which can be written without returning any integer:) Implicitly it’ll return the integer depending upon the last function call.
Please cross verify before posting an answer!!
@rohit2811995 's code is encountered with RE- NZEC and in C/C++ the major reason of getting this error is code without return 0.
and okay ‘\n’ was not needed for this problem, but it is a good practice to use ‘\n’ in print statement.!!
Yes he should have told about some more details about his problem but you may see observe that he just started his CC Career!!
And as you said adding return 0 will not work,
here is AC’ed link of his code after adding return 0;