I have been struggling with a portion of my code. I need help understanding which data type to use to get the correct number output. Your help is appreciated.
ThankS!
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
int main()
{
int num;
cout << "F) Enter the value 612.14 " << endl;
cin >> num;
cout << "" << endl;
cout << float(num) << endl; // I would like the value to show as 612.1400
cout << "" << endl;
cout << double(num) << endl; // I would like the value to show as 6.1214E+02
cout << endl;
system ("Pause");
return 0;
}

New Topic/Question
Reply




MultiQuote





|