so i was just wondering.. Why when you do math calculations people sometimes do
int, float or double? wouldnt it be best just to use float or double every time just for the possibility the user my enter in a decimal number?
Thanks..
Ex:
int X;
double F;
cout << "Enter the first number!" << endl;
cin>> X;
cout << "Enter the second number!" << endl;
cin << F;
wouldnt it be best just to use float or double every time just for the possibility the user my enter in a decimal number?
no, the best would be to accept a string because that is what the user enters. Later you may convert it to the required data type e.g. with stringstream