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

×

https://www.codechef.com/problems/HS08TEST

Whenever run this code i get wrong answer can someone help me in notifying the error: code:

include<iostream>

include<iomanip>

using namespace std; int main() { int x,i; float bal; cout<<"\nEnter the balance amount"; cin>>bal; cout<<"\nEnter withdraw amount"; cin>>x; if(x%5==0 && x+0.5<bal) { bal=bal-x-0.50; cout<<setprecision(2)<<bal; } else cout<<setprecision(2)<<bal; return 0; }

asked 08 Aug '18, 19:46

srini99's gravatar image

1★srini99
111
accept rate: 0%


you used unnecessary
cout<<"\nEnter the balance amount";
cout<<"\nEnter withdraw amount";
which are not present in output.

you have taken variable x at place of bal.
and you didnot used fixed before setprecision(2).
hopefully you understand why you got WA.

link
This answer is marked "community wiki".

answered 09 Aug '18, 01:49

apamit11's gravatar image

1★apamit11
775
accept rate: 16%

wikified 18 Aug '18, 14:10

don't put the unnecessary thing in your output. Not even newline before output.

link
This answer is marked "community wiki".

answered 09 Aug '18, 02:00

apamit11's gravatar image

1★apamit11
775
accept rate: 16%

wikified 18 Aug '18, 14:10

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:

×189

question asked: 08 Aug '18, 19:46

question was seen: 107 times

last updated: 18 Aug '18, 14:10