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

×

[closed] Why my ATM code is wrong????

#include<stdio.h>
int main()
{
    float bal,output;
    int input;
    scanf("%d %f",&input,&bal);

    if(input>=0 && input<=bal+0.5 && input<=bal)
    {
        if(input%5==0)
        {
            output=bal-input-0.5;
            printf("\n%.2f\n",output);
        }else
            printf("%.2f",bal);
    }
}

asked 03 Oct '17, 19:08

hardy_971's gravatar image

1★hardy_971
51
accept rate: 0%

closed 03 Oct '17, 22:28

vijju123's gravatar image

5★vijju123 ♦♦
15.5k12066

time to close the question as the issue has been resolved. @vijju123

(03 Oct '17, 20:39) raj792★

The question has been closed for the following reason "The question is answered, right answer was accepted" by vijju123 03 Oct '17, 22:28


it should be input+0.5<=bal in your test condition

link

answered 03 Oct '17, 19:14

viralivora's gravatar image

4★viralivora
1838
accept rate: 14%

input<=bal+0.5

I think the +0.5 should be with input. Meaning, it should be like "Balance<=Amount to withdraw +0.5"

link

answered 03 Oct '17, 19:14

vijju123's gravatar image

5★vijju123 ♦♦
15.5k12066
accept rate: 18%

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
×12

question asked: 03 Oct '17, 19:08

question was seen: 230 times

last updated: 03 Oct '17, 22:28