LearnFrenzy
Sign in Take a free test

Floating Point Issues · Floating Point MCQ · Question 8

Best way to store money amounts in C Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 8 Back to Exercise

How should a billing program store rupee amounts?

  • A float
  • B An integer number of paise (e.g. long long) Correct
  • C double
  • D A string
Correct Answer: Option B

Binary floating point cannot represent amounts like 0.10 exactly, so totals drift and equality checks fail. Whole paise in a 64-bit integer are exact; convert to rupees only when printing.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links