Formatted Console IO Operations

C++ supports a number of features that could be used for formatting the output. These features include: ios class functions and flags. Manipulators. User-defined output functions. 1. ios Class functions and flags The ios class contains a large number of member functions that could be used to format the output in a number of ways. The most important ones among them are listed below. Function Syntax Use width() cout.width(size); To specify the required field size for displaying an output value. precision() cout.precision(2); To specify the number of digits to be…

Read More

Manipulators

Manipulators are used to manage the output stream and to modify the user output. Different manipulators are used to set different output formats. Manipulators are operator that are used to format the data display. The most commonly manipulators are endl and setw. To use various manipulators in C++ program <iomanip.h> header file is compulsory to include. List of Manipulators endl setw setfill internal setprecision showpoint fixed scientific endl – endline manipulator The endl manipulator, when used in an output statement, causes a line feed to be insert. Just like a…

Read More