You are not logged in. Please login at www.codechef.com to post your questions!

×

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; }

asked 25 Jun '14, 22:47

pravi1's gravatar image

2★pravi1
62
accept rate: 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 :)

Here is the corrected code here

link

answered 25 Jun '14, 22:54

bipin2's gravatar image

3★bipin2
3.1k254671
accept rate: 8%

edited 25 Jun '14, 23:03

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 : Code

link

answered 25 Jun '14, 23:00

the65bit's gravatar image

4★the65bit
1.1k101328
accept rate: 13%

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

link

answered 25 Jun '14, 23:01

prerakd's gravatar image

3★prerakd
691316
accept rate: 0%

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;

}

link

answered 25 Jul '16, 22:36

manan904's gravatar image

2★manan904
1
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×190

question asked: 25 Jun '14, 22:47

question was seen: 693 times

last updated: 25 Jul '16, 22:36