Sunteți pe pagina 1din 7

LAB ASSIGNMENTS

PROGRAMMING PRACTICES USING C++ (Code: CS593)

FOR 5THSEM B. TECH CSE

(2012-2013)

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING B. P. PODDAR INSTITUTE OF MANAGEMENT & TECHNOLOGY

WBUT SYLLABUS

Programming Practices Using C++ Code: CS593 Contact: 3P(1L+2P) Credits: 2

Introduction of UNIX/Linux Operating System which includes preliminary commands, startup & shutdown methodology, file handling as well as introduction to editors like Vi editor, introduction to GNU C & C++ compiler, as well as introduction to GNU & GDB script. [4P] Introduction to C++, basic loop control, executing programs, writing functions, selection statements, review of functions and parameters, command line arguments, recursion, I/O streams, arraysand string manipulation, pointers, structures & unions. [6P]

Object-Oriented Programming in C++, fundamentals of classes, constructors-destructors. Dealing with member functions, operator overloading and polymorphism (both static & dynamic).[6P] Dealing with inheritance, derived class handling, abstract class, virtual class, overriding, template class, name-space & exception handling.[4P] Dynamic memory allocation, implementation of Linked Lists, using C++.[4P]

Chapter 01: Classes and Objects


Accessing Class Members
ASSIGNMENT 01: Write the definition for a class called Rectangle that has floating point data members length and width. The class has the following member functions: void setlength(float) to set the length data member void setwidth(float) to set the width data member float perimeter() to calculate and return the perimeter of the rectangle float area() to calculate and return the area of the rectangle void show() to display the length and width of the rectangle intsameArea(Rectangle) that has one parameter of type Rectangle. sameArea returns 1 if the two Rectangles have the same area, and returns 0 if they don't. 1. Write main function to create two rectangle objects. Set the length and width of the first rectangle to 5 and 2.5. Set the length and width of the second rectangle to 5 and 18.9. Display each rectangle and its area and perimeter. 2. Check whether the two Rectangles have the same area and print a message indicating the result. Set the length and width of the first rectangle to 15 and 6.3. Display each Rectangle and its area and perimeter again. Again, check whether the two Rectangles have the same area and print a message indicating the result. ASSIGNMENT 02: Write a program using basic concept of objects and classes to check whether given number is prime or not.

Data Hiding
ASSIGNMENT 03: Create a class called carpart that has int member data for car id, int member data for charge/hour and float member data for time. Set the data and show the charges and parked hours of corresponding car id. Make two member functions for setting and showing the data. Member function should be called from other functions. ASSIGNMENT 04: Let us consider a shopping list of items for which we place an order with a dealer every month.The list includes details such as the code number and price of each item.We would like to perform operations such as adding an item to the list, deleting an itam from the list and printing the total value of the order.

Outside Member Functions as inline


ASSIGNMENT 05: Write a C++ program to display the date of birth of three authors using inline function. The dates of birth of the authors are passed as parameters to function.

Passing Objects as Arguments


ASSIGNMENT 06: Create a class time that has integer data members hours and minutes. The class has the following member functions: voidgettime(int, int) to set the hours and minutes data members voidputtime(void) to display the hours and minutes data members void sum(time, time) to add two times that will illustrate the concepts of Passing Objects as Arguments.

Returning Objects from Functions


ASSIGNMENT 07: Write a C++ program to add two complex numbers illustrating the concept of Returning Objects from Functions.

Friend Functions and Friend Classes


ASSIGNMENT 08: Write a C++ program to find the maximum of two numbers illustrating the concept of Friend Functions.

Static Data Member


ASSIGNMENT 09: Write a C++ program to illustrate the concept of static data members.

Static Member Functions


ASSIGNMENT 10: Write a C++ program to illustrate the concept of static member functions.

Chapter 02: Constructor and destructor


Constructor
ASSIGNMENT 11: Create a class called Box that has double data members length, breadth and height. Write a C++ program to find the volume of a box illustrating the concept of Constructor.

Constructor Overloading
ASSIGNMENT 12: Create a class called complex that has two floating point data members x and y. Write a C++ program to add two complex numbers by using multiple constructors in the class complex.

Constructors with Dynamic Operations


ASSIGNMENT 13: Write a C++ program to illustrate the concept of Constructors with Dynamic Operation new.

Copy constructor
ASSIGNMENT 14: Write a C++ program to illustrate the concept of Copy Constructors.

Creating and Deleting Dynamic Objects


ASSIGNMENT 15: Write a C++ program to create and delete dynamic objects by using dynamic operation new and delete.

this Pointer
ASSIGNMENT 16: Write a C++ program to illustrate the working of this pointer.

Destructor
ASSIGNMENT 17: Write a C++ program to implement the concept of Destructor.

Chapter 03: Operator Overloading


ASSIGNMENT 18: Write a C++ program to add, subtract, multiply and divide two complex numbers by using the concept of operator overloading.

Chapter 04: Inheritance


Multilevel Inheritance
ASSIGNMENT 19: Write a C++ program to show multilevel inheritance.

Multiple inheritance
ASSIGNMENT 20: Consider a publishing company that publishes and markets books, whose activities are shown in Figure below. Create a class publication that stores the title (string) and price (float) of a publication. Create another class sales that holds an array of three float's so that it can record the sales of a particular publication for the last three months. From these two classes, derive a new class called book that hold pages of integer type. Each of these classes should have the member functions getdata() and display().

From the publication and sales classes, derive the tape class, which adds playing time in minutes (type float). Create another class pamphlet from publication, which has no features of its own. Derive a class notice from pamphlet class having data members char whom[20] and member functions getdata() and putdata().

Hybrid Inheritance
ASSIGNMENT 21: Write a C++ program to implement hybrid inheritance.

Chapter 05: Virtual Functions & Polymorphism


ASSIGNMENT 22: Create four classes figure (base class), triangle (publicly derived from class figure), square (publicly derived from class figure) and circle (publicly derived from class figure).Write a C++ program to find the area of triangle, square and circle by using the concept of Virtual Polymorphism. All the dimensions will be entered through keyboard in the derived classes.

Runtime Polymorphism
ASSIGNMENT 23: Create three classes media(base class), book(publicly derived from class media) tape(publicly derived from class media).Write a C++ program to display the details of book(title, pages and price) and tape(title, play time and price) by using the concept of Runtime Polymorphism. The details of book (title, pages and price) and tape (title, play time and price) will be entered through keyboard in main () function.

Chapter 06: Abstract Classes


Abstract Classes
ASSIGNMENT 24: Write a C++ program to illustrate the concept of Abstract Class.

INNOVATIVE PROGRAMS
1. MINI PROJECT 01: banking-system-project using C++ 2. MINI PROJECT 02: library-management-system-project using C++ 3. MINI PROJECT 03: Student Record Systemproject using C++

S-ar putea să vă placă și