C++ Float Precision is incorrect -


i'm new programming , i'm experimenting basic programs. wrote program convert usd gbp. when run program don't exact gbp value. example if enter 5 usd program returns 3.25 gbp. however, correct value should 3.23. here code. can/will tell me i'm doing wrong? please.

#include <iostream> #include <cmath> using namespace std;  float dtp(float);  int main() { float dollar;  cout <<"enter dollar amount want converted great britain      pounds: "; cin >> dollar; float pound = dtp(dollar);     if (pound <= 1)     {     cout <<"the dollar amount entered of " << dollar <<" dollar                        equal " << pound <<" pound.";     }      else     {     cout <<"the dollar amount entered of " << dollar <<" dollars         equal " << pound <<" pounds.";     }  return 0; }  float dtp(float p) { return p * .65;  } 

according calculator, 5 * .65 = 3.25, answer you're getting.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -