I am new to C++ , I just want to output my point number to two digits. just like if the number is 3.444 , then the output should be 3.44 or if the number is 99999.4234 , then the output should be 99999.42 . How can i do this. value is dynamic. Here is my code.
#include <iomanip.h> #include <iomanip> int main() { double num1 = 3.12345678; cout << fixed << showpoint; cout << setprecision(2); cout << num1 << endl; }
but it gives me an error, undefined fixed character.
c ++
Malik
source share