SlideShare a Scribd company logo
1 of 39
Submitted by:-    Namita Pandey
2011BTechece020
                    Shiva Johari
   Introduction
   Streams & Stream Classes
   Unformatted Input Output Operations
   Formatted Console Input Output Operation
   Formatting Flags, Bit fields and setf()
   Designing Our Own Manipulators
   Managing Console I/O Operations

   INPUT & OUTPUT

   C++ supports a rich set of I/O operations

    C++ uses the concept of stream & stream
    classes
o   A sequence of bytes
o   An interface between program and device
                     INPUT          EXTRACTION
                     STREAM         FROM INPUT
INPUT                               STREAM
DEVICE


                                    PROGRAM



OUTPUT
DEVICE
                                       INSERTION
                    OUTPUT             INTO OUTPUT
                    STREAM             STREAM
 C++ contains a hierarchy of classes that are used to define
various streams



                             ios
  INPUT                                              OUTPUT
                      POINTER

          istream        streambuf         ostream


                         iostream


Istream_withassign   Iostream_withassign   Ostream_withassign
   Overloaded operators >> and <<

   get() and put() functions

 getline() and write() functions
C++ supports a number of features which can
    be used for formatting the output. These
    features include :-

   ios class functions
   Manipulators
    User-defined Manipulators
FUNCTION                        TASK

   Width()          To specify the required field size for
                      displaying the output value
   Precision()      To specify the digits to be displayed
                      after decimal point of a float value
   Fill()           To specify a character that is used to
                      fill the unused portion of a field
   Setf()           To specify format flags that can
                      control the form of output display
   Unsetf()         To clear the flags specified
MANIPULATORS          EQUIVALENT IOS FUNCTION

   setw()               width()

   setprecision()       precision()

   setfill()            fill()

   setiosflags()        setf()

   resetiosflags()      unset()
cout.width(5);                 5 4 3 1 2
cout<<543<<12<<“n”;

cout.width(5);`
cout<<543;
cout.width(5);         5 4 3          1 2
cout<<12<<“n”;
#include<iostream.h>             cout.width(8);
                                 cout << cost[i];
int main()
{                                 int value = items[i] *
     int item[4] =               cost[i];
    {10,8,12,15};                 cout.width(15);
     int cost[4] =
                                  cout << value <<“n”;
    {75,100,60,99};
     cout.width(5);
                                  sum =sum + value;
     cout << “ITEMS”;        }
     cout.width(8);               cout << “n Grand
     cout << “COST”;             Total = “;
     cout.width(15);
     cout << value<<“n”;        cout.width(2);
     sum =sum + value;           cout << sum <<“n”;
     int sum = 0;
     for(int i=0; i<4;i++)       return 0;
    {
         cout.width(5);      }
         cout << items[i];
ITEMS    COST   TOTAL VALUE
    10     15            150
    8     100           800
    12     60            720
    15     99           1485
cout.precision(3);     1.141
cout<<sqrt(2)<<“n”;   3.142
cout<<3.14159<<“n”;
cout<<2.50032<<“n”;   2.5
#include<iostream.h>
#include<conio.h>
void main()
{
        float pi=22.0/7.0;
        int I;
        cout<<“Value of pi :n “;
        for(i=1;i<=10;i++)
        {
                   cout.width(i+1);
                   cout.precision(i);
                   cout<<pi<<“n”;
        }
}
Value of pi :
3.1
3.14
3.143
3.1429
3.14286
3.142857
3.1428571
3.14285707
3.142857075
3.1428570747
cout.fill(‘*’);
cout.width(10);
cout<<5250<<“n”;

            * * * * * * 5 2 5 0
#include<iostream.h>                 cout<<“n Paddling Changednn”;
#include<conio.h>                    cout.fill(‘#’);
void main()                          cout.width(15);
{                                    cout<<12.345678<<“n”;
cout.fill(‘<‘);
                                     return 0;
cout.precision(3);                   }
for(int n=1;n<=6;n++)
{
         cout.width(5);
         cout<<n;
         cout.width(10);
         cout<<1.0/float(n)<<“n”;
         if(n==3)
             cout.fill(‘>’);
}
<<<<1<<<<<<<<<1
<<<<2<<<<<<<0.5
<<<<3<<<<<<<0.3
>>>>4>>>>>>0.25
>>>>5>>>>>>>0.2
>>>>6>>>>>0.167

Paddling Changed

#########12.346
arg1 - formatting flags defined in the class ios

arg2 - it specifies the group to which the formatting flags belongs
FORMAT REQUIRED FLAG (ARG1)                    BIT-FIELD (ARG2)

  Left-justified output         ios::left
                                                  ios::adjustfield
  Right-justified output       ios::right
                                                  ios::adjustfield
Padding after sign or base   ios::internal
                                                  ios::adjustfield
  Indicator (like +##20)

   Scientific Notation       ios::scientific
                                                  ios::floatfield
  Fixed Point notation         ios::fixed
                                                  ios::floatfield
      Decimal Base              ios::dec
                                                  ios::basefield
#include<conio.h>
#include<iostream.h>
main()
{

cout.setf(ios::fixed, ios::floatfield);
float x=1234.67 ;
cout<<x<<endl;


cout.setf(ios::scientific, ios::floatfield);
x=.123467 ;
cout<<x;

getch();

}
1234.668234

1.234672e-01
#include<iostream.h>
#include<conio.h>
void main()
{
           int num;
           cout<<“enter an integer value”;
           cin>>num;

          cout<<“The hexadecimal, octal and
          decimal representation is : ”;

          cout.setf(ios::hex, ios::basefield)
          cout<<num<<“, “;

          cout.setf(ios::oct, ios::basefield)
          cout<<num<<“, “;

          cout.setf(ios::dec, ios::basefield)
          cout<<“ and “<<num<<“ respectively”;
}
Enter an integer value : 92

The hexadecimal, octal and decimal
representation of 92 is: 5c, 134 and 92
respectively.
ostream & manipulator (ostream & output)
{
……………
…………… (code)
……………

return output;
}
 We have taken all the basic ideas about the
concepts from the book “OBJECT ORIENTED
TECHNIQUES” – by E. Balagurusamy


   Images are made in Ms- Paint


 & every thing is accompanied by ideas of our
own
The function of istream class is to :


a) inherit the properties of ios

b) Declares input functions such as
   get(), getline(), read() etc.

c) Contains overloaded extraction operator >>

d) All of the above
The function of streambuf is to :


a) provides an interface to physical devices through buffers

b) Can’t act as a base for filebuf class used for ios files

c) Declares constants and functions that are necessary for
   handling formatted i/p and o/p operations

d) None of the above
A stream is a sequence of ___________.


a) Bytes

b) Files

c) Manipulators

d) None of the above
Which are the member functions of ios class :

a) precision()

b) width()

c) fill()

d) All the above
What will be the output of following :

             cout.fill(‘*’);
             cout.precision(3);
             cout.setf(ios::internal, ios::adjustfield);
             cout.setf(ios::scientific, ios::floatfield);
             cout.width(15);

             cout<<-12.34567<<“n”;

-******1.235e+01               (.A            B.)           -*****1.235e+01




-*****.1235e+02
                                                            -*********1.236
                               (.C            D.)
a)   The __________ operator is overloaded in the istream class



a) Insertion

b) >>

c) <<

d) None of the above
Which Class is needed to be virtual in this case :

  a.) iostream
  b.) ios
  c.) istream or ostream
  d.) no one is required

                              ios
  INPUT                                                  OUTPUT
                       POINTER

          istream          streambuf         ostream


                           iostream


Istream_withassign    Iostream_withassign     Ostream_withassign
Q8.
The header file iomanip can be used in place of
iostream ??

Q9.
 programmer can’t define a manipulator that could
represent a set of formatted functions ??
What is the default precision value ??


 a.) 0                                   b.) 4




c.) 6                                    d.) 3
Managing console

More Related Content

What's hot

Formatted input and output
Formatted input and outputFormatted input and output
Formatted input and outputOnline
 
programming language in c&c++
programming language in c&c++programming language in c&c++
programming language in c&c++Haripritha
 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overviewTAlha MAlik
 
Chapter 7 - Input Output Statements in C++
Chapter 7 - Input Output Statements in C++Chapter 7 - Input Output Statements in C++
Chapter 7 - Input Output Statements in C++Deepak Singh
 
C formatted and unformatted input and output constructs
C  formatted and unformatted input and output constructsC  formatted and unformatted input and output constructs
C formatted and unformatted input and output constructsGopikaS12
 
C++11 concurrency
C++11 concurrencyC++11 concurrency
C++11 concurrencyxu liwei
 
Manipulators in c++
Manipulators in c++Manipulators in c++
Manipulators in c++Ashok Raj
 
Lecture01
Lecture01Lecture01
Lecture01Xafran
 
Abstracting over Execution with Higher Kinded Types
Abstracting over Execution with Higher Kinded TypesAbstracting over Execution with Higher Kinded Types
Abstracting over Execution with Higher Kinded TypesPhilip Schwarz
 
Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3MOHIT TOMAR
 
03. Operators Expressions and statements
03. Operators Expressions and statements03. Operators Expressions and statements
03. Operators Expressions and statementsIntro C# Book
 

What's hot (20)

Formatted input and output
Formatted input and outputFormatted input and output
Formatted input and output
 
Managing I/O in c++
Managing I/O in c++Managing I/O in c++
Managing I/O in c++
 
Manipulators
ManipulatorsManipulators
Manipulators
 
programming language in c&c++
programming language in c&c++programming language in c&c++
programming language in c&c++
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overview
 
Chapter 7 - Input Output Statements in C++
Chapter 7 - Input Output Statements in C++Chapter 7 - Input Output Statements in C++
Chapter 7 - Input Output Statements in C++
 
Introduction to C++
Introduction to C++Introduction to C++
Introduction to C++
 
C formatted and unformatted input and output constructs
C  formatted and unformatted input and output constructsC  formatted and unformatted input and output constructs
C formatted and unformatted input and output constructs
 
Al2ed chapter17
Al2ed chapter17Al2ed chapter17
Al2ed chapter17
 
C++11 concurrency
C++11 concurrencyC++11 concurrency
C++11 concurrency
 
Manipulators in c++
Manipulators in c++Manipulators in c++
Manipulators in c++
 
Introduction to Input/Output Functions in C
Introduction to Input/Output Functions in CIntroduction to Input/Output Functions in C
Introduction to Input/Output Functions in C
 
Lecture01
Lecture01Lecture01
Lecture01
 
COM1407: Input/ Output Functions
COM1407: Input/ Output FunctionsCOM1407: Input/ Output Functions
COM1407: Input/ Output Functions
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
Abstracting over Execution with Higher Kinded Types
Abstracting over Execution with Higher Kinded TypesAbstracting over Execution with Higher Kinded Types
Abstracting over Execution with Higher Kinded Types
 
Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3
 
C Programming Tutorial - www.infomtec.com
C Programming Tutorial - www.infomtec.comC Programming Tutorial - www.infomtec.com
C Programming Tutorial - www.infomtec.com
 
03. Operators Expressions and statements
03. Operators Expressions and statements03. Operators Expressions and statements
03. Operators Expressions and statements
 

Viewers also liked (20)

Input and output in c
Input and output in cInput and output in c
Input and output in c
 
C++ Files and Streams
C++ Files and Streams C++ Files and Streams
C++ Files and Streams
 
Input Output Management In C Programming
Input Output Management In C ProgrammingInput Output Management In C Programming
Input Output Management In C Programming
 
Managing input and output operation in c
Managing input and output operation in cManaging input and output operation in c
Managing input and output operation in c
 
Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++
 
Files in c++
Files in c++Files in c++
Files in c++
 
file handling c++
file handling c++file handling c++
file handling c++
 
File Handling in C++
File Handling in C++File Handling in C++
File Handling in C++
 
Unit iv
Unit ivUnit iv
Unit iv
 
Vcs26
Vcs26Vcs26
Vcs26
 
2 3. standard io
2 3. standard io2 3. standard io
2 3. standard io
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Lecture 12: Classes and Files
Lecture 12: Classes and FilesLecture 12: Classes and Files
Lecture 12: Classes and Files
 
File handling in C++
File handling in C++File handling in C++
File handling in C++
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
Chapter 2.datatypes and operators
Chapter 2.datatypes and operatorsChapter 2.datatypes and operators
Chapter 2.datatypes and operators
 
New operator and methods.15
New operator and methods.15New operator and methods.15
New operator and methods.15
 
Stream classes in C++
Stream classes in C++Stream classes in C++
Stream classes in C++
 
32.java input-output
32.java input-output32.java input-output
32.java input-output
 
Data file handling in c++
Data file handling in c++Data file handling in c++
Data file handling in c++
 

Similar to Managing console

2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_papervandna123
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical fileMitul Patel
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloadingkinan keshkeh
 
CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011Deepak Singh
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual finalAhalyaR
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101premrings
 
Computer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperComputer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperDeepak Singh
 
Lec 47.48 - stream-files
Lec 47.48 - stream-filesLec 47.48 - stream-files
Lec 47.48 - stream-filesPrincess Sam
 
Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++Marco Izzotti
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++somu rajesh
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyGrejoJoby1
 
The Ring programming language version 1.5.3 book - Part 91 of 184
The Ring programming language version 1.5.3 book - Part 91 of 184The Ring programming language version 1.5.3 book - Part 91 of 184
The Ring programming language version 1.5.3 book - Part 91 of 184Mahmoud Samir Fayed
 

Similar to Managing console (20)

C++InputOutput.pptx
C++InputOutput.pptxC++InputOutput.pptx
C++InputOutput.pptx
 
C++InputOutput.PPT
C++InputOutput.PPTC++InputOutput.PPT
C++InputOutput.PPT
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_paper
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
 
CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011
 
C++ practical
C++ practicalC++ practical
C++ practical
 
C++ Overview PPT
C++ Overview PPTC++ Overview PPT
C++ Overview PPT
 
C++
C++C++
C++
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual final
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
Computer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperComputer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paper
 
Lec 47.48 - stream-files
Lec 47.48 - stream-filesLec 47.48 - stream-files
Lec 47.48 - stream-files
 
Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
 
Quiz 9
Quiz 9Quiz 9
Quiz 9
 
Lecture2.ppt
Lecture2.pptLecture2.ppt
Lecture2.ppt
 
CP 04.pptx
CP 04.pptxCP 04.pptx
CP 04.pptx
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
 
The Ring programming language version 1.5.3 book - Part 91 of 184
The Ring programming language version 1.5.3 book - Part 91 of 184The Ring programming language version 1.5.3 book - Part 91 of 184
The Ring programming language version 1.5.3 book - Part 91 of 184
 

Recently uploaded

ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 

Recently uploaded (20)

ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 

Managing console

  • 1. Submitted by:- Namita Pandey 2011BTechece020 Shiva Johari
  • 2. Introduction  Streams & Stream Classes  Unformatted Input Output Operations  Formatted Console Input Output Operation  Formatting Flags, Bit fields and setf()  Designing Our Own Manipulators
  • 3. Managing Console I/O Operations  INPUT & OUTPUT  C++ supports a rich set of I/O operations  C++ uses the concept of stream & stream classes
  • 4. o A sequence of bytes o An interface between program and device INPUT EXTRACTION STREAM FROM INPUT INPUT STREAM DEVICE PROGRAM OUTPUT DEVICE INSERTION OUTPUT INTO OUTPUT STREAM STREAM
  • 5.  C++ contains a hierarchy of classes that are used to define various streams ios INPUT OUTPUT POINTER istream streambuf ostream iostream Istream_withassign Iostream_withassign Ostream_withassign
  • 6. Overloaded operators >> and <<  get() and put() functions  getline() and write() functions
  • 7. C++ supports a number of features which can be used for formatting the output. These features include :-  ios class functions  Manipulators  User-defined Manipulators
  • 8. FUNCTION TASK  Width()  To specify the required field size for displaying the output value  Precision()  To specify the digits to be displayed after decimal point of a float value  Fill()  To specify a character that is used to fill the unused portion of a field  Setf()  To specify format flags that can control the form of output display  Unsetf()  To clear the flags specified
  • 9. MANIPULATORS EQUIVALENT IOS FUNCTION  setw()  width()  setprecision()  precision()  setfill()  fill()  setiosflags()  setf()  resetiosflags()  unset()
  • 10. cout.width(5); 5 4 3 1 2 cout<<543<<12<<“n”; cout.width(5);` cout<<543; cout.width(5); 5 4 3 1 2 cout<<12<<“n”;
  • 11. #include<iostream.h> cout.width(8); cout << cost[i]; int main() { int value = items[i] * int item[4] = cost[i]; {10,8,12,15}; cout.width(15); int cost[4] = cout << value <<“n”; {75,100,60,99}; cout.width(5); sum =sum + value; cout << “ITEMS”; } cout.width(8); cout << “n Grand cout << “COST”; Total = “; cout.width(15); cout << value<<“n”; cout.width(2); sum =sum + value; cout << sum <<“n”; int sum = 0; for(int i=0; i<4;i++) return 0; { cout.width(5); } cout << items[i];
  • 12. ITEMS COST TOTAL VALUE 10 15 150 8 100 800 12 60 720 15 99 1485
  • 13. cout.precision(3); 1.141 cout<<sqrt(2)<<“n”; 3.142 cout<<3.14159<<“n”; cout<<2.50032<<“n”; 2.5
  • 14. #include<iostream.h> #include<conio.h> void main() { float pi=22.0/7.0; int I; cout<<“Value of pi :n “; for(i=1;i<=10;i++) { cout.width(i+1); cout.precision(i); cout<<pi<<“n”; } }
  • 15. Value of pi : 3.1 3.14 3.143 3.1429 3.14286 3.142857 3.1428571 3.14285707 3.142857075 3.1428570747
  • 17. #include<iostream.h> cout<<“n Paddling Changednn”; #include<conio.h> cout.fill(‘#’); void main() cout.width(15); { cout<<12.345678<<“n”; cout.fill(‘<‘); return 0; cout.precision(3); } for(int n=1;n<=6;n++) { cout.width(5); cout<<n; cout.width(10); cout<<1.0/float(n)<<“n”; if(n==3) cout.fill(‘>’); }
  • 19. arg1 - formatting flags defined in the class ios arg2 - it specifies the group to which the formatting flags belongs
  • 20. FORMAT REQUIRED FLAG (ARG1) BIT-FIELD (ARG2) Left-justified output ios::left ios::adjustfield Right-justified output ios::right ios::adjustfield Padding after sign or base ios::internal ios::adjustfield Indicator (like +##20) Scientific Notation ios::scientific ios::floatfield Fixed Point notation ios::fixed ios::floatfield Decimal Base ios::dec ios::basefield
  • 21. #include<conio.h> #include<iostream.h> main() { cout.setf(ios::fixed, ios::floatfield); float x=1234.67 ; cout<<x<<endl; cout.setf(ios::scientific, ios::floatfield); x=.123467 ; cout<<x; getch(); }
  • 23. #include<iostream.h> #include<conio.h> void main() { int num; cout<<“enter an integer value”; cin>>num; cout<<“The hexadecimal, octal and decimal representation is : ”; cout.setf(ios::hex, ios::basefield) cout<<num<<“, “; cout.setf(ios::oct, ios::basefield) cout<<num<<“, “; cout.setf(ios::dec, ios::basefield) cout<<“ and “<<num<<“ respectively”; }
  • 24. Enter an integer value : 92 The hexadecimal, octal and decimal representation of 92 is: 5c, 134 and 92 respectively.
  • 25. ostream & manipulator (ostream & output) { …………… …………… (code) …………… return output; }
  • 26.
  • 27.  We have taken all the basic ideas about the concepts from the book “OBJECT ORIENTED TECHNIQUES” – by E. Balagurusamy  Images are made in Ms- Paint  & every thing is accompanied by ideas of our own
  • 28.
  • 29.
  • 30. The function of istream class is to : a) inherit the properties of ios b) Declares input functions such as get(), getline(), read() etc. c) Contains overloaded extraction operator >> d) All of the above
  • 31. The function of streambuf is to : a) provides an interface to physical devices through buffers b) Can’t act as a base for filebuf class used for ios files c) Declares constants and functions that are necessary for handling formatted i/p and o/p operations d) None of the above
  • 32. A stream is a sequence of ___________. a) Bytes b) Files c) Manipulators d) None of the above
  • 33. Which are the member functions of ios class : a) precision() b) width() c) fill() d) All the above
  • 34. What will be the output of following : cout.fill(‘*’); cout.precision(3); cout.setf(ios::internal, ios::adjustfield); cout.setf(ios::scientific, ios::floatfield); cout.width(15); cout<<-12.34567<<“n”; -******1.235e+01 (.A B.) -*****1.235e+01 -*****.1235e+02 -*********1.236 (.C D.)
  • 35. a) The __________ operator is overloaded in the istream class a) Insertion b) >> c) << d) None of the above
  • 36. Which Class is needed to be virtual in this case : a.) iostream b.) ios c.) istream or ostream d.) no one is required ios INPUT OUTPUT POINTER istream streambuf ostream iostream Istream_withassign Iostream_withassign Ostream_withassign
  • 37. Q8. The header file iomanip can be used in place of iostream ?? Q9. programmer can’t define a manipulator that could represent a set of formatted functions ??
  • 38. What is the default precision value ?? a.) 0 b.) 4 c.) 6 d.) 3