ATM : SOLUTIONS MATCHING BUT WRONG ANSWER

LINK TO MY SUBMISSION : https://www.codechef.com/problems/HS08TEST

PLEASE LET ME KNOW ! WHERE I HAVE BEEN STUCKED!

thanks in advance,
regards
thiyagarajan

1 Like

Remember 0.5 dollars charge for each transaction ???

Let’s assume you had 5 dollars in your account… And you withdraw 5 dollars from it…
Now what about 0.5 dollars charge ??? bank cannot allow negative balance :smiley:
so you need to check…

 if( X+0.5 less than Y) 

instead of

if(X less than Y) 

thanks bro @l_returns !

welcome bro :slight_smile:

#include <stdio.h>

void money(int X,float Y){
if(X%5==0){
if((X+0.5)<=Y){
printf("%.2f",(Y-(X+0.5)));
}
else
{
printf("%.2f",Y);
}

}
else{
    printf("%.2f",Y);
}

}

int main(void) {
// your code goes here
int x;
float y;
money(x,y);
return 0;
}

Can you please tell whats wrong in these

You forgot to take the input.
Just take the input , else everything seems fine.

2 Likes