Page 273 - DCAP404 _Object Oriented Programming
P. 273

Object-oriented Programming




                    Notes          3.  no skipws: Its purpose is not to skip white space on input.
                                   4.  dec: it is used for the decimal conversion.
                                   5.  oct; : It is used for the octal conversion.
                                   6.  hex: It is used for hexadecimal conversion.

                                   7.  left; This manipulator is used to left align and pad on right in the field.
                                   8.  right: This manipulator is used to right align and pad on left in the field.
                                   9.  internal: It is used for padding between sign or base indicator and value.
                                   10.  showpos: Shows plus sign for positive values.

                                   11.  noshowpos: Do not show plus sign for positive value.
                                   12.  uppercase: It displays uppercase A-F for hex values and E for Scientific values.
                                   13.  no upper case: It do not display hex values in upper case.
                                   14.  show point: It shows decimal point and trailing zeros for float values.

                                   15.  scientific: It uses scientific notation for printing float value.
                                   16.  fixed: It uses fixed notation for printing float values.
                                   17.  ends; it inserts null character to terminate an output string.
                                   18.  flush; It flushes the output stream.

                                   19.  lock: It unlocks the file handling.


                                          Example: Let us consider an example to understand the usage of above said manipulators:
                                   #include<iostream.h>
                                   #include<conio.h>
                                   #include<iomanip.h>
                                   void  main(  )
                                   {
                                          int  I  =  2b;
                                          float  b  =  123.500032;

                                          char  str[  ]  =  “I  am  a  c++  programmer”;
                                          clrscr(  );
                                   cout<<setios  flags  (ios:  :unitbuf  |  ios:  :stdio  |  ios::  showpos);
                                          cout<<i<<end  l;
                                          cout<< set  iosflogs(ios  ::  showbase  |  ios  ::  uppercase);
                                          cout  <<  hex  <<  i  <<  end;
                                          cout  <  <  oct  <<  i  <<  endl;

                                          cout  <  <  set  fill  (‘o’);
                                          cout  <<  set  w  (40)  <<str  <<  endl;






          266                               LOVELY PROFESSIONAL UNIVERSITY
   268   269   270   271   272   273   274   275   276   277   278