Manipulators

675 views

Published on

Published in: Education, Technology, Spiritual
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
675
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
36
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Manipulators

  1. 1. Manipulators INTRODUCTION 2. ENDL 3. SETW() 4. SETFILL() 1. Compiled By: Kamal Acharya
  2. 2. Introduction  Manipulators are instructions to the output stream that modify the output in various ways.  They are of two types one taking arguments and other without arguments   Non-argument manipulators Eg. Endl Argumented manipulators Eg. Setw(),setfill() Compiled By: Kamal Acharya
  3. 3. Endl  Its function is the same as the “n” in C.  More then that it not only transfer the control to the new line but also flush the output buffer. Compiled By: Kamal Acharya
  4. 4. Setw()  This manipulator sets the minimum field width on output  SYNTAX:      Setw(x); It causes the number or string that follows to be printed within the field x. The header file <iomanip.h> should be included while using it. The content is right justified For left justification –x should be used Compiled By: Kamal Acharya
  5. 5. Sample Program #include<iostream.h> #include<conio.h> #include<iomanip.h> int main() { clrscr(); cout<<setw(10)<<"Check"<<endl; cout<<setw(-10)<<"Check"<<endl; getch(); return 0; } Compiled By: Kamal Acharya
  6. 6. Setfill()  This is used after setw() manipulator.  It fills up the unused field assigned by the setw() manipulators with the character passed as argument to it.  SYNTAX:  Setfill(‘$’); Compiled By: Kamal Acharya
  7. 7. Sample Program #include<iostream.h> #include<conio.h> #include<iomanip.h> int main() { clrscr(); cout<<setw(10)<<setfill('$')<<"Check"<<endl; cout<<setw(-10)<<setfill('$')<<"Check"<<endl; getch(); return 0; } Compiled By: Kamal Acharya

×