I am a C++ newbie and having a problem with my first program. I’m trying to multiply two float numbers and the result always show like 1.1111e+1 where 1s are the random numbers. Following is the little program I wrote.
#include <iostream>
#include <string>
#include <conio.h>
using namespace std;
int main()
{
float bank;
float dollor;
cout<<"Enter amount of $ deposited at Bank: ";//the data to input is 5000
cin>>bank;
cout<<"Enter current $ price: ";//1usd = 800mmk: the data to input is 800
cin>>dollor;
bank*=dollor;//all deposited $ to local currency
cout<<"Result is "<<bank;
getch();
}
and the result of this program is 4e+006.
ps: I declared as float in order to input floats sometime.
Please help me with this program where I was wrong. Thanks all..
4e+006is the scientific notation for4000000, which is the correct answer to5000*800.To elaborate,
4e+006stands for4 * 10**6, where10**6is ten to the sixth power.To use the fixed-point notation, you could change your program like so: