123456789101112131415161718192021222324
#include <iostream> #include <iomanip> using namespace std; int main() { cout << "\nDisplay arithmetic operations with mixed data type : " << endl; cout << "-------------------------------------------------" << endl; cout << "5 + 7 = " << 5 + 7 << endl; cout << "3.7 + 8.0 = " << 3.7 + 8.0 << endl; cout << "5 + 8.0 = " << fixed << setprecision(1) << 5 + 8.0 << endl; //line I'm targeting cout << "5 - 7 = " << 5 - 7 << endl; cout << "3.7 - 8.0 = " << 3.7 - 8.0 << endl; cout << "5 - 8.0 = " << 5 - 8.0 << endl; cout << "5 * 7 = " << 5 * 7 << endl; cout << "3.7 * 8.0 = " << 3.7 * 8.0 << endl; cout << "5 * 8.0 = " << 5 * 8.0 << endl; cout << "5 / 7 = " << 5 / 7 << endl; cout << "3.7 / 8.0 = " << 3.7 / 8.0 << endl; cout << "5 / 8.0 = " << 5 / 8.0 << endl; return 0; }
cout << "5 + 8.0 = " << fixed << setprecision(1) << 5 + 8.0 << defaultfloat << setprecision(6) << '\n';
setprecision(6)