C++ examples for File Stream:cout
Floating-Point Numbers, Scientific and Fixed Notation (scientific, fixed)
#include <iostream> int main(int argc, const char *argv[]) { double x = 0.001234567; double y = 1.946e9; // display x and y in default format std::cout << "Displayed in default format:" << std::endl << x << '\t' << y << std::endl; // display x and y in scientific format std::cout << "\nDisplayed in scientific format:" << std::endl << std::scientific << x << '\t' << y << std::endl; // display x and y in fixed format std::cout << "\nDisplayed in fixed format:" << std::endl << std::fixed << x << '\t' << y << std::endl; return 0;//from ww w .ja v a 2 s . co m }