INSTITUTE - UIE
DEPARTMENT- ACADEMIC UNITS
Bachelor of Engineering (Computer Science & Engineering)
Subject Name: Basic Data Structure Using C++
Code:24CSH-103
Topic: Input and output streams DISCOVER . LEARN . EMPOWER
Basic Data Structure
Using C++
Course Objectives
• To enable the students to understand
various stages and constructs of C++
programming language.
• To improve their ability to analyze and
address variety of problems in C++.
• To understand the concept of data
structures and various operations on
them.
• To understand the properties of
various data structures and able to
identify the strengths and weaknesses
of different data structures.
• To analyze and compare the efficiency
of algorithms and learn to design
2
efficient algorithms for solving
Course Outcomes
CO Course Outcome
Number
CO1 Understand the concepts of object-oriented programming including
programming process and compilation process.
CO2 Apply different techniques to decompose a problem and
programmed a solution with various concepts of object-oriented
programming language.
CO3 Analyse and explain the behaviour of linear data structure
operations using the programming addressed in the course.
CO4 Implement and evaluate the programs using the syntax and
semantics of object-oriented programming.
CO5 Design the solution of real-world problems in order to determine
that the program performs as expected.
3
Scheme of Evaluation
Direct Evaluation Weightage of actual Final Weightage in Mapping with SIs Remarks
Sl No. Frequency of Task BT Levels CO Mapping Mapping with PIs
Instruments conduct Internal Assessment (ABET) (Graded/Non-Graded)
SO1 1a,1b,1c
10 marks for each
1 Assignment One per unit 10 Hard CO4,CO5 Graded
assignment
SO6
2 Exam 20 marks for one MST 2 per semester 20 Medium CO1,CO2,CO3,CO4 6a,6b Graded
3 Case Study 8 marks 1 per unit 8 Easy CO2 SO1, SO6 1c,6b Graded
NA NA NA NA
One per lecture
4 Homework NA topic (of 2 NA Non-Graded
questions)
NA NA NA NA
5 Discussion Forum NA One per unit NA Non-Graded
NA NA NA NA
6 Presentation NA NA NA Non-Graded
7 Attendance NA NA 2 NA NA NA NA Graded
Remarks
Direct Evaluation Final Weightage in Mapping with SIs
S No. Weightage of actual conduct Frequency of Task BT Levels CO Mapping Mapping with PIs (Graded/Non-
Instruments Internal Assessment (ABET)
Graded)
Unit wise Practical 1a, 1b, 1c, 6a, 6b SO1, SO6
1 15 marks 3 45 Medium 1,2,3,4,5 Graded
Evaluation
1a, 1b, 1c, 6a, 6b
2 Exam 15 marks for one MST 1 per semester 15 Medium 1,2,3 SO1, SO6 Graded
3 Attendance NA NA 2 NA NA NA NA Graded
4
CONTENTS
• Input and output streams
(cin, cout)
5
Input and output streams (cin, cout)
• C++ comes with libraries that provide us with many ways for
performing input and output. In C++ input and output are performed in
the form of a sequence of bytes or more commonly known as streams.
• Input Stream: If the direction of flow of bytes is from the device(for
example, Keyboard) to the main memory then this process is called
input.
• Output Stream: If the direction of flow of bytes is opposite, i.e. from
main memory to device( display screen ) then this process is called
output.
6
Header files available in C++ for Input/Output operations are:
• iostream: iostream stands for standard input-output stream. This header file
contains definitions to objects like cin, cout, cerr etc.
• iomanip: iomanip stands for input output manipulators. The methods
declared in this files are used for manipulating streams. This file contains
definitions of setw, setprecision, etc.
• fstream: This header file mainly describes the file stream. This header file is
used to handle the data being read from a file as input or data being written
into the file as output.
• The two keywords cout and cin in C++ are used very often for printing
outputs and taking inputs respectively. These two are the most basic
methods of taking input and printing output in C++. To use cin and cout in C+
+ one must include the header file iostream in the program.
7
Standard output stream (cout):
• Usually the standard output device is the display screen.
• The C++ cout statement is the instance of the ostream class.
• It is used to produce output on the standard output device which is usually the
display screen.
• The data needed to be displayed on the screen is inserted in the standard output
stream (cout) using the insertion operator(<<).
• Example:
#include <iostream>
using namespace std;
int main()
{
char sample[] = "GeeksforGeeks";
cout << sample << " - A computer science portal for geeks";
return 0;
}
8
Standard input stream (cin):
• Usually the input device in a computer is the keyboard.
• C++ cin statement is the instance of the class istream and is used to read input from the
standard input device which is usually a keyboard.
• The extraction operator(>>) is used along with the object cin for reading inputs.
• The extraction operator extracts the data from the object cin which is entered using the
keyboard.
• Example:
#include <iostream>
using namespace std;
int main()
{
int age;
cout << "Enter your age:";
cin >> age;
cout << "\nYour age is: " << age;
return 0;
}
9
Summary
In this lecture we have We have discussed about
discussed about difference various data types in C++
between structure and class.
Moreover we have learnt
about basic i/o in c++
10
Frequently Asked question
Q1 What is the difference between structure and class?
C++ is an object oriented language that mainly focuses on objects. A class in C++ can be defined as a collection of related
variables and functions encapsulated in a single structure. Instances of the class are termed as objects. A structure in C++
can be referred to as an user defined data type possessing its own operations. Unlike in the C language, they both are quite
similar in C++. The main difference that exists between them is regarding the access modifier; the members of a class are
private by default, whereas members of a struct are public by default.
A class in C++ is just an extension of a structure used in the C language. It is a user defined data type. It actually binds the
data and its related functions in one unit. A structure and a class in C language differs a lot as a structure has limited
functionality and features as compared to a class. On the other hand, structure and class in C++ are quite similar. The main
difference arises due to the fact that by default, all the members of a class are private, whereas by default all the members of
a structure are public.
Structure is also a user defined data type with a certain template. It is generally used for grouping of logically related data
items. After the creation of a structure, the variables pertaining to the type of structure can be defined and used. A structure is
used to represent a record. In C++, a structure can have both data members and functions as classes. Many people find it
difficult to differenciate between a class and a structure. Technically they both are regarded as the same in C++.
11
Q2 What are the various I/O in C++?
Answer: C++ comes with libraries that provide us with many ways for
performing input and output. In C++ input and output are performed in
the form of a sequence of bytes or more commonly known as streams.
Input Stream: If the direction of flow of bytes is from the device(for
example, Keyboard) to the main memory then this process is called
input.
Output Stream: If the direction of flow of bytes is opposite, i.e. from
main memory to device( display screen ) then this process is called
output
12
Assessment Questions:
1. What is size of void in bytes?
(A) 1
(B) 2
(C) 4
(D) 0
2. What is the size of empty class?
(A) 0
(B) 1
(C) 2
(D) 4
3. Which is not an integer data type?
(A) Single
(B) Byte
(C) Short
(D) Integer
13
Discussion forum.
A deeper dive into Data Types in C++
https://www.youtube.com/watch?v=qa960QezGDE
14
REFERENCES
TEXT BOOKS
T1 E Balagurusamy., “Object Oriented Programming in C++”, Tata McGraw-Hill.
T2 Robert Lafore, “Object Oriented Programming in C++”, Waite Group.
REFERENCE BOOKS
R1 Herbert Schildt , “C++- The Complete Reference”, Tata McGraw-Hill 2003, New Delhi.
R2 Bjarne Stroustrup: “The C++ Programming Language” (4th Edition). Addison-Wesley.
R3 Ravichandran , “Programming with C++”,Tata McGraw-Hill Education.
R4 Joyce M. Farrell,” Object Oriented Programming Using C++”, Learning.
R5 Programming Languages: Design and Implementation (4th Edition), by Terrence W.
Pratt, Marvin V. Zelkowitz, Pearson.
R6 Programming Language Pragmatics, Third Edition, by Michael L. Scott, Morgan
Kaufmann.
Websites:
1. https://www.tutorialspoint.com/What-is-the-difference-between-cin-and-cout-str
eams-in-cplusplus#:~:text=cin%20is%20an%20object%20of,They%20also%20
use%20different%20operators
.
2. https://www.geeksforgeeks.org/basic-input-output-c/
3. http://www.differencebetween.info/difference-between-class-and-structure-in-cp 15
lusplus
THANK YOU