Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Lesson2 Basic Input Output in C

This document provides an overview of basic input/output operations in C++ using streams, detailing the standard input and output streams such as cin and cout. It outlines the objectives for students to understand C++ input/output functions and the importance of specific operators and syntax. Additionally, it includes resources for further learning and references for educational materials related to C++ programming.

Uploaded by

jervinbucu30
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Lesson2 Basic Input Output in C

This document provides an overview of basic input/output operations in C++ using streams, detailing the standard input and output streams such as cin and cout. It outlines the objectives for students to understand C++ input/output functions and the importance of specific operators and syntax. Additionally, it includes resources for further learning and references for educational materials related to C++ programming.

Uploaded by

jervinbucu30
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

DON HONORIO VENTURA STATE

UNIVERSITY
Cabambangan, Villa de Bacolor 2001, Pampanga,

BASIC INPUT/OUTPUT
IN C++

Description
C++ uses a convenient abstraction called streams to perform input and
output operations in sequential media such as the screen, the keyboard or a
file. A stream is an entity where a program can either insert or extract
characters to/from. There is no need to know details about the media
associated to the stream or any of its internal specifications. All we need to
know is that streams are a source/destination of characters, and that these
characters are provided/accepted sequentially (i.e., one after another).

Objectives
After completing the module, the students are expected to:
 Understand the input/output functions of C++ programming language
 Familiarize with the terms used in C++ programming language
 Able to construct the basic structure of C++
 Able to write codes using C++ programming language in
Dev C++ IDE Instructions

 Engage students with the topic by demonstrating them how to construct


functions in Dev C++ IDE.
 Elaborate each function to have a deeper understanding in constructing
the basic C++ structure.
 Discuss content and answer questions. Check for understanding by asking:

 What are the main functions of basic input/output streams of C++?


 What are the two main operators used in input/output streams of C++?
 How important is the semicolon ( ; ) in constructing C++ language?
 What is the function of double quotation marks (“ “)?
DON HONORIO VENTURA STATE
UNIVERSITY
Cabambangan, Villa de Bacolor 2001, Pampanga,

Resources (Educational Materials):


url: videos: https://www.youtube.com/watch?
https://goalkicker.com/CPlusPlusBook/ v=vLnPwxZdW4Y
https://www.w3schools.com/cpp/cpp_getstarted.asp https://www.youtube.com/watch?v=_bYFu9mBnr4
http://www.cplusplus.com/info/description/ https://www.youtube.com/watch?v=JBjjnqG0BP8
https://www.programiz.com/cpp-programming
https://www.studytonight.com/cpp/introduction-to-
cpp.php
https://docs.oracle.com/cd/E19957-01/806-
3569/Standard.html
https://docs.microsoft.com/en-us/cpp/standard-
library/iostream?view=vs-2019
https://www.softwaretestinghelp.com/iomanip-
functions-in-cpp/

Basic Input / Output

The standard library defines a handful of stream objects that can be used to access
what are considered the standard sources and destinations of characters by the
environment where the program runs:

STREA DESCRIPTION
M
cin Standard input stream
cout Standard output stream
cerr Standard error (output)
stream
clog Standard logging (output)
stream

Standard output (cout)

The << operator inserts the data that follows it into the stream that precedes it. In the
examples above, it inserted the literal string Output sentence, the number 120, and the
value of variable x into the standard output stream cout. Notice that the sentence in the
first statement is enclosed in double quotes (")
DON HONORIO VENTURA STATE
UNIVERSITY
Cabambangan, Villa de Bacolor 2001, Pampanga,

because it is a string literal, while in the last one, x is not. The double quoting is what
makes the difference; when the text is enclosed between them, the text is printed literally;
when they are not, the text is interpreted as the identifier of a variable, and its value is
printed instead. For example, these two sentences have very different results:

Multiple insertion operators (<<) may be chained in a single statement:

“\n (new-line)” and “endl (end-of-line)” functions

 \n or new-line – this is the insertion function of a line break. A new-line


character shall be inserted at the exact position the line should be broken.

 endl or end-of-line – an alternative function to break lines

Output will be:


First sentence.
Second sentence.

Standard input (cin)

For formatted input operations, cin is used together with the extraction operator, which is written as >>
(i.e., two "greater than" signs). This operator is then followed by the variable where the extracted data is stored.
DON HONORIO VENTURA STATE
UNIVERSITY
Cabambangan, Villa de Bacolor 2001, Pampanga,

References:

 Goodrich, Michael et.al (2011). Data Structures and Algorithms in C++. John Wiley & Sons Inc,
United States of America
 Educational Technology Journals. http://www.educational-software-directory.net/publications/journals
 CPlusPlusNotesForProfessionals. http://www.GoalKicker.com
 C++ Tutorials. http://www.programiz.com
 C++ Tutorials. http://www.w3schools.in

You might also like