Computer Science - Object Oriented Programming Using C++ - Discussion


Format flags may be combined using

[A]. the bitwise OR operator (|)
[B]. the logical OR operator (||)
[C]. the bitwise AND operator (&)
[D]. the logical AND operator (&&)

Answer: Option A


No answer description available for this question.

Vinay said: (Mar 8, 2011)  
Can anybody tell me what is format flag ?

Anshuman said: (Mar 15, 2011)  
Actually bitwise OR operator is denoted by pipe symbol (|) which is use to combine.

Anshuman Kansal said: (Mar 15, 2011)  
The class ios contains data members to store all the formatting information pertaining to a stream. Some of this data has a range of values and is stored in variables: the floating-point precision, the output field width, and the character used to pad the output (normally a space). The rest of the formatting is determined by flags, which are usually combined to save space and are referred to collectively as the format flags.

Sharanya said: (Jan 17, 2012)  
Actually what are format flags?

Kiran said: (Jan 20, 2012)  
The <iostream> library defines a rich set of format flags. These flags enable you to control the width, alignment, precision, and so on for the displayed data.

Shiva said: (Jan 21, 2012)  
Actually what are format flags?

Sundar said: (Jan 27, 2012)  
Let me explain in clear.

// Assume two 16-bit flags contains values as given below
intFlag1 = (00000000 10101010) In Binary.
intFlag2 = (00000010 01010101) In Binary.

// Now combine it with Bitwise-OR operator
intResult = intFlag1 | intFlag2 ;

// The combined result will be.
intResult = (00000010 11111111) In Binary.

Hope this will help you. Have a nice day!

Rewg said: (Sep 3, 2015)  
But I don't get clear idea about format flags.

Muhammad Usman said: (Oct 9, 2015)  
Can any one explain that what are format flags?

Soia said: (Nov 4, 2015)  
What is member function?

G V said: (Aug 5, 2016)  
I didn't get this question? Please explain me.

Gursimran said: (Sep 2, 2016)  
Thanks @Sundar. It helps me. :)

Preet said: (Nov 1, 2016)  
It is denoted by the virtual number.

Somya Agrawal said: (Dec 14, 2016)  
What are format flags? Please describe it in detail.

Johny said: (Mar 19, 2017)  
It is actually very beneficial. Thanks @Sunder.

Tushar said: (Jun 20, 2017)  
Can anyone tell me what is format flags, and what is its use?

Jayasree said: (Jul 29, 2017)  
Please, be clear what are format flags?

Shashank Singh said: (Sep 4, 2017)  
cout and cin contain several single-bit flags for format control. They are named in an enum in class ios as:

ios::skipws // skips whitspace on input
ios::left // left justification
ios::right // right justifiction
ios::internal // pads after sign or base character
ios::dec // decimal format for integers
ios::oct // octal format for integers
ios::hex // hex format for integers
ios::showbase // show the base character for octal or hex
ios::showpoint // show the decimal point for all floats
ios::uppercase // uppercase A-F for hex
ios::showpos // show +ve sign for numbers
ios::scientific // use exponential notation
ios::fixed // used oridnary decimal notation
ios::unitbuf // flush the buffer

These flags can be set with the member function setf. e.g.


They can be or'd together:
cout.setf(ios::showpos | ios::uppercase);
or some bits can be unset while one is being set:
cout.setf(ios::oct, ios::dec | ios::oct | ios::hex);

This sets the bit for oct, after unsetting the bits for oct, dec and hex, ensuring that only one of the bits is turned on.
unsetf turns bits off:

Aakash Kr said: (Apr 15, 2018)  
Realy, I want to know what is format flag?

Taruni said: (Jul 28, 2018)  
What is meant by format flag?

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.