#include#include int main() { int x = 123; std::cout << "Default: " << x << std::endl; std::cout.setf(std::ios::dec); std::cout << "Decimal: " << x << std::endl; std::cout.setf(std::ios::hex); std::cout << "Hexadecimal: " << x << std::endl; std::cout.setf(std::ios::oct); std::cout << "Octal: " << x << std::endl; return 0; }
#includeThis code sets the format flags for a stream to display the double value in scientific and fixed-point notation. The `setf()` function is part of the C++ Standard Library, which is a collection of functions, classes, and templates that provide basic functionality to C++ programs.#include int main() { double x = 3.14159; std::cout << "Default format: " << x << std::endl; std::cout.setf(std::ios::scientific, std::ios::floatfield); std::cout << "Scientific format: " << x << std::endl; std::cout.unsetf(std::ios::scientific); std::cout.setf(std::ios::fixed, std::ios::floatfield); std::cout << "Fixed-point format: " << x << std::endl; return 0; }