what is problem with my atm code?

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

int x,m;
float y,k,i=0.50;
printf(“input:\n”);
scanf("%d\t%f",&x,&y);
//scanf("%f",&y);
k=y-i;
m=x%5;
if(x<y)
{
if(m!=0)

  printf("output:\n%.2f\n",y);

  else
   printf("output:\n%.2f\n",k-x);

}
if(x>y)
{
printf(“output:\n%.2f\n”,y);
}
return 0;
}

Buddy we have to print as such as in the format specified. The output they have asked is to print the balance.

No need to print input and Output and all

Hope you got what i meant :slight_smile:

Here is the corrected code here

1 Like

First of all you should not print input: and output: . Then transaction is accepted if the charges can also be subtracted , so you should compare x with k. here is your corrected code :


[1]


  [1]: http://www.codechef.com/viewsolution/4142755

There shouldn’t be anything to be printed except the answers.Not even "input " or “output”.Also you should not use “\t” during taking input as it will only accept the input if there will be tab which is not here.So you should take the input without any tab

Why am I getting wrong answer?

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

int with;
float cur;


scanf("%d", &with);
scanf("%f", &cur);


        if (with % 5 == 0 && cur - 0.5 > with)
        {
            printf("%.2f", cur-with-0.5);

        }
        else if (with % 5 != 0|| cur<=with)
                printf("%.2f", cur);

    return 0;

}

//