Introduction to C++ Programming
Course Code: 22PLC25D Credits: 3
L: P: T: S 2:2:0:0 CIE Marks: 50
Exam Hours: 3 SEE Marks: 50
Course Type: Integrated
Course Objectives:
1.Understanding about the fundamental programming concepts and methodologies which
are essential for building good C/C++ programs.
2. Understand how to design C++ classes for code reuse.
3.Understand how to implement constructors, encapsulation, overloading function,
inheritance file handling and exception handling.
4. Understand how to use exception handling in C++ programs.
Course Outcomes: At the end of the course, students will be able to:
CO1 Program solutions for real life problems using OO principles in C++.
CO2 Create UML class diagrams for given application scenarios.
CO3 Debug C++ programs by tracing through specific outputs.
CO4 Incorporate exception handling in C++ programs.
CO5 Implement Input/output operations using streams.
Mapping of Course outcomes to Program outcomes:
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
CO1 1 1 1 - - 1 - - 1 1 - 1
CO2 1 1 - - - - - - 1 2 - 1
CO3 1 1 1 - - - - - 1 1 - 1
CO4 1 1 1 - - - - - 1 1 - 1
CO5 1 1 1 - - - - - - 1 - 1
Unit Course content Hours COs
Module-1:
Introduction to Object Oriented Programming: Computer
programming background- C++ overview. First C++ Program - Basic
CO1
1 5
C++ syntax, Tokens – Keywords – Identifiers and constants – Operators CO2
in C++ – Scope resolution operator – Expressions and their types –
Special assignment expressions, what is an Object & Classes.
Module-2:
Control Statements: if-else, switch, Looping statement: while, Do-
while, for. CO1
CO2
2 8
Functions in C++: Function prototyping – Call by reference – Return by
reference – Inline functions -Default arguments, Objects &Classes,
Constructors & destructor, this pointer, static keyword, friend function.
Module-3:
Inheritance: Defining Derived classes & base classes, Single
CO1
Inheritance, Multiple, Hierarchical Inheritance, Hybrid Inheritance.
3 9 CO2
CO3
Polymorphism: Function Overloading & overriding and virtual
functions.
Module-4:
Exception Handling: Introduction to Exception - Benefits of Exception
CO1
4
9 CO2
handling- Try and catch block Throw statement- Pre-defined exceptions
CO4
in C++.
Module-5:
I/O Stream: C++ Class Hierarchy- File Stream-Text File Handling- CO4
5 9
CO5
Binary File Handling during file operations.
Pre-requisites:
Module 1: NO Pre-requisite required
Module 2: Basic knowledge of keywords, identifiers and operators.
Module 3: Knowledge about control statements, and function types.
Module 4: Knowledge about Inheritance and polymorphism.
Module 5: Knowledge about exception handling.
Self-Study Component:
NOTE: 1. Questions for CIE and SEE not to be set from Self Study Component.
2. Assignment Questions should be only from Self Study Component.
Module 1: Namespaces, strings
Module 2: Pointers
Module 3: Arrays
Module 4: Abstraction
Module 5: Signal Handling
Textbooks
1. Balagurusamy E, Object Oriented Programming with C++, Tata McGraw Hill Education
Pvt.Ltd, Fourth Edition 2010.
2. Bhushan Trivedi, “Programming with ANSI C++”, Oxford Press, Second Edition, 2012.
Reference Books:
1. E. Balaguruswamy, Object Oriented Programming With C++, McGraw-Hill Education
(India) Pvt Limited, 2008.
Web links and Video Lectures (e-Resources):
1. Basics of C++ - https://www.youtube.com/watch?v=BClS40yzssA
2. Functions of C++ - https://www.youtube.com/watch?v=p8ehAjZWjPw
Tutorial Link:
1. https://www.w3schools.com/cpp/cpp_intro.asp
2. https://www.edx.org/course/introduction-to-c-3
Lab Assignments
Write a C++ program to read two numbers from the keyboard and display the larger value on the
1.
screen.
Write a C++ program to find the sum of all the natural numbers from 1 to n.
2.
Write a C++ program to swap 2 values by writing a function that uses call by reference technique.
3.
Write a C++ program to demonstrate function overloading for the following prototypes.
4.
add(int a, int b) add(double a, double b).
Create a class named Shape with a function that prints "This is a shape". Create another class
named Polygon inheriting the Shape class with the same function that prints "Polygon is a
shape". Create two other classes named Rectangle and Triangle having the same function
5.
which prints "Rectangle is a polygon" and "Triangle is a polygon" respectively. Again, make
another class named Square having the same function which prints "Square is a rectangle".
Now, try calling the function by the object of each of these classes.
Suppose we have three classes Vehicle, Four-Wheeler, and Car. The class Vehicle is the base
class, the class Four-Wheeler is derived from it and the class Car is derived from the class
Four-Wheeler. Class Vehicle has a method 'vehicle' that prints 'I am a vehicle', class Four-
6.
Wheeler has a method 'four-Wheeler' that prints 'I have four wheels', and class Car has a
method 'car' that prints 'I am a car'. So, as this is a multi-level inheritance; we can have access
to all the other classes methods from the object of the class Car. We invoke all the methods
from a Car object and print the corresponding outputs of the methods. So, if we invoke the
methods in this order, car(), four Wheeler(), and vehicle(), then the output will be
I am a car
I have four wheels
I am a vehicle
Write a C++ program to demonstrate multilevel inheritance using this.
Write a C++ program to create a text file, check file created or not, if created it will write
7.
some text into the file and then read the text from the file.
Write a C++ program to write and read time in/from binary file using fstream.
8.
Write a function which throws a division by zero exception and catch it in catch block. Write
9.
a C++ program to demonstrate usage of try, catch and throw to handle exception.
Write a C++ program function which handles array of bounds exception using C++.
10.