22PLC25D - Introduction to C++ Programming
22PLC25D - Introduction to C++ Programming
Course Objectives:
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++.
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:
Module-2:
Module-3:
functions.
Module-4:
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:
Self-Study Component:
NOTE: 1. Questions for CIE and SEE not to be set from Self Study Component.
2. Bhushan Trivedi, “Programming with ANSI C++”, Oxford Press, Second Edition, 2012.
Reference Books:
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 am a vehicle
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.