ATM wrong answer

#include<stdio.h>
int main()
{

int w;

float b;

scanf("%d %f",&w,&b);

if((w%5==0)&&(w<=b))

printf("%\n.2f",(b-w-0.5));

else

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

return 0;

}

test your program, its showing wrong ans for every testcase

check your print statement

1 Like

Check the printf() statement. That is wrong way to print out a float with 2 decimal points.

Change that to…

printf("%.2f\n",...);
1 Like

changed it but still wrong answer

“The cash machine will only accept the transaction if X is a multiple of 5, and Pooja’s account balance has enough cash to perform the withdrawal transaction (including bank charges).” Now check when w == b or (b - w) < 0.50 .

When w=0 and b=120.00 then expected answer is 120.00 but your answer is 119.50. and when w=120 and b=120.00 then expected answer is 120.00 because account balance isn’t negative but your answer is -0.50.
So, please correct your code and any help then check this link -

 http://www.codechef.com/viewsolution/4122388 

.

friend, you have made many mistakes

  1. when the complier starts he sees the main program but from where does the calculation in main program start you need to uses brace { and } for starting the body or you know the statements of main() function … so he will be able to know
  2. you havent used any header fle for eg stdio.h which contains the defination of printf so obiviously it will give you a error that is he is not able to find the protype of printf statement… note: header files are necessary
//