SlideShare a Scribd company logo
1 of 13
Object Oriented Programming: 14
Output Formatting using
Manipulators
Prof Neeraj Bhargava
Vaibhav Khanna
Department of Computer Science
School of Engineering and Systems Sciences
Maharshi Dayanand Saraswati University Ajmer
2
Output and Formatting Output
• Syntax of cout when used with <<
• Expression is evaluated
• Value is printed
• Manipulator is used to format the output
– Example: endl
3
setprecision Manipulator
• Syntax:
• Outputs decimal numbers with up to n
decimal places
• Must include the header file iomanip:
– #include <iomanip>
4
fixed Manipulator
• fixed outputs floating-point numbers in a
fixed decimal format
– Example: cout << fixed;
– Disable by using the stream member function
unsetf
• Example: cout.unsetf(ios::fixed);
• The manipulator scientific is used to
output floating-point numbers in scientific
format
5
showpoint Manipulator
• showpoint forces output to show the
decimal point and trailing zeros
• Examples:
– cout << showpoint;
– cout << fixed << showpoint;
6
setw
• Outputs the value of an expression in
specific columns
– cout << setw(5) << x << endl;
• If number of columns exceeds the number
of columns required by the expression
– Output of the expression is right-justified
– Unused columns to the left are filled with
spaces
• Must include the header file iomanip
7
Additional Output Formatting Tools
• Additional formatting tools that give you more
control over your output:
– setfill manipulator
– left and right manipulators
– unsetf manipulator
8
setfill Manipulator
• Output stream variables can use setfill to
fill unused columns with a character
• Example:
– cout << setfill('#');
9
left and right Manipulators
• left: left-justifies the output
• Disable left by using unsetf
• right: right-justifies the output
10
Types of Manipulators
• Two types of manipulators:
– With parameters
– Without parameters
• Parameterized: require iomanip header
– setprecision, setw, and setfill
• Nonparameterized: require iostream
header
– endl, fixed, showpoint, left, and flush
11
Input/Output and the string Type
• An input stream variable (cin) and >>
operator can read a string into a variable of
the data type string
• Extraction operator
– Skips any leading whitespace characters and
reading stops at a whitespace character
• The function getline
– Reads until end of the current line
12
File Input/Output
• File: area in secondary storage to hold info
• File I/O is a five-step process
1. Include fstream header
2. Declare file stream variables
3. Associate the file stream variables with the
input/output sources
4. Use the file stream variables with >>, <<, or
other input/output functions
5. Close the files
Assignment
• Explain the formatting of Output using
manipulators in C++

More Related Content

What's hot

Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programmingprogramming9
 
C OPERATOR
C OPERATORC OPERATOR
C OPERATORrricky98
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++Online
 
Operators and Expressions in C++
Operators and Expressions in C++Operators and Expressions in C++
Operators and Expressions in C++Praveen M Jigajinni
 
Managing input and output operations in c
Managing input and output operations in cManaging input and output operations in c
Managing input and output operations in cniyamathShariff
 
2.1 input and output in c
2.1 input and output in c2.1 input and output in c
2.1 input and output in cJawad Khan
 
Input output statement in C
Input output statement in CInput output statement in C
Input output statement in CMuthuganesh S
 
3 operators-expressions-and-statements-120712073351-phpapp01
3 operators-expressions-and-statements-120712073351-phpapp013 operators-expressions-and-statements-120712073351-phpapp01
3 operators-expressions-and-statements-120712073351-phpapp01Abdul Samee
 
Data Input and Output
Data Input and OutputData Input and Output
Data Input and OutputSabik T S
 
Relational operators In C language (By: Shujaat Abbas)
Relational operators In C language (By: Shujaat Abbas)Relational operators In C language (By: Shujaat Abbas)
Relational operators In C language (By: Shujaat Abbas)Shujaat Abbas
 
03. operators and-expressions
03. operators and-expressions03. operators and-expressions
03. operators and-expressionsStoian Kirov
 
1.2 programming fundamentals
1.2 programming fundamentals1.2 programming fundamentals
1.2 programming fundamentalsJawad Khan
 
Lecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operatorsLecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operatorseShikshak
 
Operators-computer programming and utilzation
Operators-computer programming and utilzationOperators-computer programming and utilzation
Operators-computer programming and utilzationKaushal Patel
 
Increment and Decrement operators in C++
Increment and Decrement operators in C++Increment and Decrement operators in C++
Increment and Decrement operators in C++Neeru Mittal
 
2. operators in c
2. operators in c2. operators in c
2. operators in camar kakde
 
Operators in c language
Operators in c languageOperators in c language
Operators in c languageAmit Singh
 

What's hot (19)

Operators in C & C++ Language
Operators in C & C++ LanguageOperators in C & C++ Language
Operators in C & C++ Language
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
C OPERATOR
C OPERATORC OPERATOR
C OPERATOR
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++
 
Operators and Expressions in C++
Operators and Expressions in C++Operators and Expressions in C++
Operators and Expressions in C++
 
Managing input and output operations in c
Managing input and output operations in cManaging input and output operations in c
Managing input and output operations in c
 
2.1 input and output in c
2.1 input and output in c2.1 input and output in c
2.1 input and output in c
 
Input output statement in C
Input output statement in CInput output statement in C
Input output statement in C
 
3 operators-expressions-and-statements-120712073351-phpapp01
3 operators-expressions-and-statements-120712073351-phpapp013 operators-expressions-and-statements-120712073351-phpapp01
3 operators-expressions-and-statements-120712073351-phpapp01
 
Data Input and Output
Data Input and OutputData Input and Output
Data Input and Output
 
Relational operators In C language (By: Shujaat Abbas)
Relational operators In C language (By: Shujaat Abbas)Relational operators In C language (By: Shujaat Abbas)
Relational operators In C language (By: Shujaat Abbas)
 
03. operators and-expressions
03. operators and-expressions03. operators and-expressions
03. operators and-expressions
 
1.2 programming fundamentals
1.2 programming fundamentals1.2 programming fundamentals
1.2 programming fundamentals
 
Lecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operatorsLecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operators
 
Operators-computer programming and utilzation
Operators-computer programming and utilzationOperators-computer programming and utilzation
Operators-computer programming and utilzation
 
Increment and Decrement operators in C++
Increment and Decrement operators in C++Increment and Decrement operators in C++
Increment and Decrement operators in C++
 
2. operators in c
2. operators in c2. operators in c
2. operators in c
 
Operators in c language
Operators in c languageOperators in c language
Operators in c language
 
P3
P3P3
P3
 

Similar to Object oriented programming 14 output formatting using manipulators

Similar to Object oriented programming 14 output formatting using manipulators (20)

Formatted input and output
Formatted input and outputFormatted input and output
Formatted input and output
 
C++ Ch3
C++ Ch3C++ Ch3
C++ Ch3
 
Object oriented programming 13 input stream and devices in cpp
Object oriented programming 13 input stream and devices in cppObject oriented programming 13 input stream and devices in cpp
Object oriented programming 13 input stream and devices in cpp
 
Basic Elements of C++
Basic Elements of C++Basic Elements of C++
Basic Elements of C++
 
C++ ch2
C++ ch2C++ ch2
C++ ch2
 
Manipulators
ManipulatorsManipulators
Manipulators
 
Basic elements of java
Basic elements of java Basic elements of java
Basic elements of java
 
c-programming
c-programmingc-programming
c-programming
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
MPMC
MPMC MPMC
MPMC
 
Object oriented programming 10 variables input and output
Object oriented programming 10 variables input and outputObject oriented programming 10 variables input and output
Object oriented programming 10 variables input and output
 
Floating point arithmetic operations (1)
Floating point arithmetic operations (1)Floating point arithmetic operations (1)
Floating point arithmetic operations (1)
 
Object oriented programming 12 programming steps in cpp and example
Object oriented programming 12 programming steps in cpp and exampleObject oriented programming 12 programming steps in cpp and example
Object oriented programming 12 programming steps in cpp and example
 
Lecture2.ppt
Lecture2.pptLecture2.ppt
Lecture2.ppt
 
Input and Output
Input and OutputInput and Output
Input and Output
 
ARM Processors
ARM ProcessorsARM Processors
ARM Processors
 
Unit 2.ppt
Unit 2.pptUnit 2.ppt
Unit 2.ppt
 
Lesson 4.1 completing the problem solving process
Lesson 4.1 completing the problem solving processLesson 4.1 completing the problem solving process
Lesson 4.1 completing the problem solving process
 
Raptor tool
Raptor toolRaptor tool
Raptor tool
 
Fundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptxFundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptx
 

More from Vaibhav Khanna

Information and network security 47 authentication applications
Information and network security 47 authentication applicationsInformation and network security 47 authentication applications
Information and network security 47 authentication applicationsVaibhav Khanna
 
Information and network security 46 digital signature algorithm
Information and network security 46 digital signature algorithmInformation and network security 46 digital signature algorithm
Information and network security 46 digital signature algorithmVaibhav Khanna
 
Information and network security 45 digital signature standard
Information and network security 45 digital signature standardInformation and network security 45 digital signature standard
Information and network security 45 digital signature standardVaibhav Khanna
 
Information and network security 44 direct digital signatures
Information and network security 44 direct digital signaturesInformation and network security 44 direct digital signatures
Information and network security 44 direct digital signaturesVaibhav Khanna
 
Information and network security 43 digital signatures
Information and network security 43 digital signaturesInformation and network security 43 digital signatures
Information and network security 43 digital signaturesVaibhav Khanna
 
Information and network security 42 security of message authentication code
Information and network security 42 security of message authentication codeInformation and network security 42 security of message authentication code
Information and network security 42 security of message authentication codeVaibhav Khanna
 
Information and network security 41 message authentication code
Information and network security 41 message authentication codeInformation and network security 41 message authentication code
Information and network security 41 message authentication codeVaibhav Khanna
 
Information and network security 40 sha3 secure hash algorithm
Information and network security 40 sha3 secure hash algorithmInformation and network security 40 sha3 secure hash algorithm
Information and network security 40 sha3 secure hash algorithmVaibhav Khanna
 
Information and network security 39 secure hash algorithm
Information and network security 39 secure hash algorithmInformation and network security 39 secure hash algorithm
Information and network security 39 secure hash algorithmVaibhav Khanna
 
Information and network security 38 birthday attacks and security of hash fun...
Information and network security 38 birthday attacks and security of hash fun...Information and network security 38 birthday attacks and security of hash fun...
Information and network security 38 birthday attacks and security of hash fun...Vaibhav Khanna
 
Information and network security 37 hash functions and message authentication
Information and network security 37 hash functions and message authenticationInformation and network security 37 hash functions and message authentication
Information and network security 37 hash functions and message authenticationVaibhav Khanna
 
Information and network security 35 the chinese remainder theorem
Information and network security 35 the chinese remainder theoremInformation and network security 35 the chinese remainder theorem
Information and network security 35 the chinese remainder theoremVaibhav Khanna
 
Information and network security 34 primality
Information and network security 34 primalityInformation and network security 34 primality
Information and network security 34 primalityVaibhav Khanna
 
Information and network security 33 rsa algorithm
Information and network security 33 rsa algorithmInformation and network security 33 rsa algorithm
Information and network security 33 rsa algorithmVaibhav Khanna
 
Information and network security 32 principles of public key cryptosystems
Information and network security 32 principles of public key cryptosystemsInformation and network security 32 principles of public key cryptosystems
Information and network security 32 principles of public key cryptosystemsVaibhav Khanna
 
Information and network security 31 public key cryptography
Information and network security 31 public key cryptographyInformation and network security 31 public key cryptography
Information and network security 31 public key cryptographyVaibhav Khanna
 
Information and network security 30 random numbers
Information and network security 30 random numbersInformation and network security 30 random numbers
Information and network security 30 random numbersVaibhav Khanna
 
Information and network security 29 international data encryption algorithm
Information and network security 29 international data encryption algorithmInformation and network security 29 international data encryption algorithm
Information and network security 29 international data encryption algorithmVaibhav Khanna
 
Information and network security 28 blowfish
Information and network security 28 blowfishInformation and network security 28 blowfish
Information and network security 28 blowfishVaibhav Khanna
 
Information and network security 27 triple des
Information and network security 27 triple desInformation and network security 27 triple des
Information and network security 27 triple desVaibhav Khanna
 

More from Vaibhav Khanna (20)

Information and network security 47 authentication applications
Information and network security 47 authentication applicationsInformation and network security 47 authentication applications
Information and network security 47 authentication applications
 
Information and network security 46 digital signature algorithm
Information and network security 46 digital signature algorithmInformation and network security 46 digital signature algorithm
Information and network security 46 digital signature algorithm
 
Information and network security 45 digital signature standard
Information and network security 45 digital signature standardInformation and network security 45 digital signature standard
Information and network security 45 digital signature standard
 
Information and network security 44 direct digital signatures
Information and network security 44 direct digital signaturesInformation and network security 44 direct digital signatures
Information and network security 44 direct digital signatures
 
Information and network security 43 digital signatures
Information and network security 43 digital signaturesInformation and network security 43 digital signatures
Information and network security 43 digital signatures
 
Information and network security 42 security of message authentication code
Information and network security 42 security of message authentication codeInformation and network security 42 security of message authentication code
Information and network security 42 security of message authentication code
 
Information and network security 41 message authentication code
Information and network security 41 message authentication codeInformation and network security 41 message authentication code
Information and network security 41 message authentication code
 
Information and network security 40 sha3 secure hash algorithm
Information and network security 40 sha3 secure hash algorithmInformation and network security 40 sha3 secure hash algorithm
Information and network security 40 sha3 secure hash algorithm
 
Information and network security 39 secure hash algorithm
Information and network security 39 secure hash algorithmInformation and network security 39 secure hash algorithm
Information and network security 39 secure hash algorithm
 
Information and network security 38 birthday attacks and security of hash fun...
Information and network security 38 birthday attacks and security of hash fun...Information and network security 38 birthday attacks and security of hash fun...
Information and network security 38 birthday attacks and security of hash fun...
 
Information and network security 37 hash functions and message authentication
Information and network security 37 hash functions and message authenticationInformation and network security 37 hash functions and message authentication
Information and network security 37 hash functions and message authentication
 
Information and network security 35 the chinese remainder theorem
Information and network security 35 the chinese remainder theoremInformation and network security 35 the chinese remainder theorem
Information and network security 35 the chinese remainder theorem
 
Information and network security 34 primality
Information and network security 34 primalityInformation and network security 34 primality
Information and network security 34 primality
 
Information and network security 33 rsa algorithm
Information and network security 33 rsa algorithmInformation and network security 33 rsa algorithm
Information and network security 33 rsa algorithm
 
Information and network security 32 principles of public key cryptosystems
Information and network security 32 principles of public key cryptosystemsInformation and network security 32 principles of public key cryptosystems
Information and network security 32 principles of public key cryptosystems
 
Information and network security 31 public key cryptography
Information and network security 31 public key cryptographyInformation and network security 31 public key cryptography
Information and network security 31 public key cryptography
 
Information and network security 30 random numbers
Information and network security 30 random numbersInformation and network security 30 random numbers
Information and network security 30 random numbers
 
Information and network security 29 international data encryption algorithm
Information and network security 29 international data encryption algorithmInformation and network security 29 international data encryption algorithm
Information and network security 29 international data encryption algorithm
 
Information and network security 28 blowfish
Information and network security 28 blowfishInformation and network security 28 blowfish
Information and network security 28 blowfish
 
Information and network security 27 triple des
Information and network security 27 triple desInformation and network security 27 triple des
Information and network security 27 triple des
 

Recently uploaded

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 

Recently uploaded (20)

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 

Object oriented programming 14 output formatting using manipulators

  • 1. Object Oriented Programming: 14 Output Formatting using Manipulators Prof Neeraj Bhargava Vaibhav Khanna Department of Computer Science School of Engineering and Systems Sciences Maharshi Dayanand Saraswati University Ajmer
  • 2. 2 Output and Formatting Output • Syntax of cout when used with << • Expression is evaluated • Value is printed • Manipulator is used to format the output – Example: endl
  • 3. 3 setprecision Manipulator • Syntax: • Outputs decimal numbers with up to n decimal places • Must include the header file iomanip: – #include <iomanip>
  • 4. 4 fixed Manipulator • fixed outputs floating-point numbers in a fixed decimal format – Example: cout << fixed; – Disable by using the stream member function unsetf • Example: cout.unsetf(ios::fixed); • The manipulator scientific is used to output floating-point numbers in scientific format
  • 5. 5 showpoint Manipulator • showpoint forces output to show the decimal point and trailing zeros • Examples: – cout << showpoint; – cout << fixed << showpoint;
  • 6. 6 setw • Outputs the value of an expression in specific columns – cout << setw(5) << x << endl; • If number of columns exceeds the number of columns required by the expression – Output of the expression is right-justified – Unused columns to the left are filled with spaces • Must include the header file iomanip
  • 7. 7 Additional Output Formatting Tools • Additional formatting tools that give you more control over your output: – setfill manipulator – left and right manipulators – unsetf manipulator
  • 8. 8 setfill Manipulator • Output stream variables can use setfill to fill unused columns with a character • Example: – cout << setfill('#');
  • 9. 9 left and right Manipulators • left: left-justifies the output • Disable left by using unsetf • right: right-justifies the output
  • 10. 10 Types of Manipulators • Two types of manipulators: – With parameters – Without parameters • Parameterized: require iomanip header – setprecision, setw, and setfill • Nonparameterized: require iostream header – endl, fixed, showpoint, left, and flush
  • 11. 11 Input/Output and the string Type • An input stream variable (cin) and >> operator can read a string into a variable of the data type string • Extraction operator – Skips any leading whitespace characters and reading stops at a whitespace character • The function getline – Reads until end of the current line
  • 12. 12 File Input/Output • File: area in secondary storage to hold info • File I/O is a five-step process 1. Include fstream header 2. Declare file stream variables 3. Associate the file stream variables with the input/output sources 4. Use the file stream variables with >>, <<, or other input/output functions 5. Close the files
  • 13. Assignment • Explain the formatting of Output using manipulators in C++