laboratory manual · 1. the students must complete the weekly assignments well in activities/ time...

36
Laboratory Manual MCA I Semester Laboratory Course–I: CSM – 11P1 Department of Computer Science Aligarh Muslim University, Aligarh

Upload: others

Post on 03-Aug-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

Laboratory Manual MCA I Semester

Laboratory Course–I: CSM – 11P1

Department of Computer Science

Aligarh Muslim University, Aligarh

Page 2: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 2

AM

U

AM

U

AM

U

AM

U

Credits Lab Manual Design Committee:

Prof. Mohammad Ubaidullah Bokhari

Dr. Arman Rasool Faridi

Dr. Faisal Anwar

Dr. Aasim Zafar (Convener)

The Committee thankfully acknowledges the efforts and contributions of the

following Instructors:

Mr. Sunil Kumar Sharma

Mr. Md. Naved Iqbal

Mr. Imshad Ahmad Khan

Design & Compilation:

Mr. Sunil Kumar Sharma First Edition: July 2017 Department of Computer Science, A.M.U., Aligarh, (U.P.), India

Page 3: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 3

AM

U

AM

U

AM

U

AM

U

Rules and Regulations

Students are required to strictly adhere to the following rules.

1. The students must complete the weekly activities/assignments well in

time (i.e., within the same week).

2. The students must maintain the Lab File of their completed

activities/assignments in the prescribed format (Appendix-1).

3. The students must get the completed weekly activities/assignments

checked and signed by the concerned teachers in the Lab in the

immediate succeeding week. Failing which the activities/assignments

for that week will be treated as incomplete.

4. At least TEN (10) such timely completed and duly signed weekly

activities/assignments are compulsory, failing which students will not

be allowed to appear in the final Lab Examination.

Page 4: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 4

AM

U

AM

U

AM

U

AM

U

APPENDIX-1

Template for the Index of Lab File

S.NO. LABS# Date of

Submission

Signature

of the

Teacher

Remarks

1

WE

EK

#1

Lab#1 Activity

Assignment

LAB#2 Activity

Assignment

Lab#3 Activity

Assignment

2

WE

EK

#2

Lab#4 Activity

Assignment

LAB#5 Activity

Assignment

Lab#6 Activity

Assignment

Note: The students should use Header and Footer mentioning their roll no. & name in footer and page no in header.

Page 5: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 5

AM

U

AM

U

AM

U

AM

U

WEEK #1 OBJECTIVE:

To learn using MS-Word. To learn the practical use of MS-Word tool.

OUTCOMES: After completing this Lab, the students would be able to use

MS-Word for real life applications. Open a new document and type the following letter.

July 15, 2016, Chennai.

From VENKATESH .P Sri Ranga Apartments, No: 120, II Avenue, T. Nagar. Chennai-17 To <<Name>> <<Address>> Respected <<Name>> With the current slowdown in hiring within the high- tech field, you must be flooded with resumes from out-placed software engineers such as me. Please take a moment to consider my qualifications. I believe in particular is highly marketable in this tight market: I worked on the team that pioneered the technology that put the Palm Pilot on the map. In today’s increasingly mobile society, this technology has places to go, and I have ideas that could take us to the next step in office independence. Please call me with prospective job opportunities. I am interested in a project management position in the Rs. 9K range. Thank you! Venkatesh. Enclosure: Resume (the format given below). i) Save the document as “Letter.doc.” ii) Send the document to 3 recipients using Mail merge. (Use 3 different

addresses) iii) Define a Macro ‘Decorate’ which makes the text bold, Red in color

and italic, font size Assign a shortcut key Alt + Z to this macro. iv) Close the document.

LAB – 1-2-3 A

ct

ivit

y

Page 6: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 6

AM

U

AM

U

AM

U

AM

U

The Sample Addresses are: i) Mr. Amit Tandon 13, New Estate, Ring Road, Chandigarh ii) Mr. Rohit Saluja 15, Karol Bagh, New Delhi iii) Ms. Jyoti Parmar Sector 16, New Building, Gurugram

Format of Resume Name : Father’s Name : Date of Birth : Age : Address : Educational Qualification : Sr. No. Qualification Board/University Percentage

Work Experience : Technical Skills : Personal Skills : Hobbies :

Dated:…………………. Signature

Create a table in word as shown below:

Roll No Name Marks in Physics

Marks in Chemistry

Total Marks

1 Sakshi 80 70 2 Rohit 70 80 3 Amit 60 50 4 Rakesh 40 60 5 Komal 30 70 6 Garima 80 80

Do the following: (a) In the total marks column, entries should be calculated using

formulas and it is the sum of marks in physics and marks in chemistry.

(b) Insert a new row at the end of the table and also find grand total using formula.

(c) Sort the table based on total marks. (d) The date and heading should be center aligned. (e) Heading should be in bold and underlined.

As

sig

nm

en

t

Page 7: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 7

AM

U

AM

U

AM

U

AM

U

WEEK #2 OBJECTIVE:

To learn using MS-Excel, MS-Access, MS-Power Point & MS-Front Page.

To learn the practical use of MS-Excel, MS-Access, MS-Power Point & MS-Front Page tool.

To learn using HTML Tags. To learn the practical use of Ms-Power Point. To learn the Practical use of HTML.

OUTCOMES:

After completing this Lab, the students would be able to use MS-Excel, MS-Access, MS-Power Point & MS-Front Page. In real life applications.

Student would be able to create a simple web site.

Using a spreadsheet package you have studied, construct T Morongo’s pay slip for December 2016 following the instructions below. Insert a custom footer with your name, subject, course, exam/Test & question number. Save it as Salary advice.

SALARY ADVICE FOR MARCH 2016 EMPLOYEE T MARONGO STAFF NO 004 DATE 31 MARCH 2016 NEXT PAY DATE 30 APRIL 2016

BASIC SALARY p.a. 31200.00

INCOME AMOUNT DEDUCTIONS AMOUNT Basic Salary Pension @8%

Housing Subsidy P.A.Y.E.

Vehicle Allowance U.I.F.

Medical Aid

Ac

tiv

ity

LAB – 4

Page 8: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 8

AM

U

AM

U

AM

U

AM

U

Bond Repayment Gross Income Total Deductions Net Salary

Instructions: i) Housing Subsidy 6000.00 per year. ii) Car Allowance 100.00 per month, iii) Pension 8% on Basic Salary. iv) P.A.Y.E. 636.83 v) Medical Aid 70.00 vi) U.I.F. 1% on Basic Salary + Housing Subsidy vii) Bond Repayment 630.00 viii) Calculate Net Salary

ix) Format all figures to two decimal places and insert ₹ currency symbol.

x) Insert a custom footer with your name, subject, and question number. Save it as salary advice2

A Use a new workbook & construct a worksheet with the data given & save it as LYONS.

LYONS INC Orange JUICE Sales

PRODUCT COST PRICE

PER LITRE

MARK UP

PER ITEM 35%

SELLING PRICE

LITRES SOLD

TOTAL INCOME

PROFIT

Cascade 3.75 234 Quench 3.65 345 Xtra 4.25 456 Sun Splash 1.50 123

House Brand 1.50 245 TOTAL HIGHEST LOWEST

Instructions Markup = Cost price/Litre x 35% Selling price= Cost price/Litre + Mark up Total income= Litres sold x Selling Price Profit = Total income – (Cost price/Litre x Litres sold)

a) The MARKUP % (35%) must be inserted in a separate cell under the heading. USE IT as an absolute cell reference in the formula to calculate the markup per item.

b) Calculate the mark up for each item. c) Calculate the selling price for each item. d) Calculate the Total Income for each item. e) Calculate the profit for each item.

As

sig

nm

en

t

Page 9: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 9

AM

U

AM

U

AM

U

AM

U

f) Format the column LITRES SOLD to display the number of litres as integers. The rest of the worksheet must be formatted to display two decimals.

g) Use statistical functions to calculate the: AVERAGE HIGHEST (MAX) LOWEST (MIN) for Selling Price column up to Profit Column.

h) Show all formulas you have used in a new sheet. Adjust the column width so that the formulae are displayed in full and the sheets fits into one side of A4 landscape format and save it as formulas.

i) Under the worksheet Create a pie chart titled PRODUCT COST PER UNIT for Product & Cost price per Litre columns. Data labels indicating percentages should be displayed.

j) Put borders neatly on the on the work sheet & save it as LYONS2.

i) Create a new database, save it on the desktop and name it “School Database”

ii) Create a Table in the School Database with the following: iii) Make the “ID Number” Field as the Primary Key. iv) Save the table as “Student’s Table” v) Return to the main Access window. vi) Open the “Students Table” and enter 5 complete records. vii) Sort the table in ascending order by surname viii) Move the Date of Birth and Telephone Number fields so that the

Date of Birth field is now directly after the Surname field. ix) Delete the last Record you have entered x) Change the field size of the Surname to 20. xi) Create a Form with all fields on the Student’s Table. xi) Name the form Students Entries xii) Make the ID Number of Each student in the form, Red xiii) Insert a Picture in the form in way that all text is visible. xiv) Create a report based on the Student’s Table showing the Fields

Name, Surname, and Telephone Number. xv) Name the report Telephone List xvi) Insert a picture in the report Header. xvii) Create a query, showing all fields of those students who have a

particular surname of your Choice. xviii) Create another query showing all fields of those students born

after 1987. xix) Create a query showing only the Student’s Name, Surname and

Date of birth.

LAB – 5

Ac

tiv

ity

Page 10: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 10

AM

U

AM

U

AM

U

AM

U

Data Entry Form From the Database Window, make sure the STUDENTS table is selected. From the Insert menu, select AutoForm. A form will be created automatically using the Fields and Records from your table. You can move from one record or Field to another using your mouse or the keyboard. Use any of the above methods to move to a new, blank record. Complete the form. Use the form to add the records 4 to 6 as shown below. Student Number; Last Name; First Name; Date of Birth; Address; Suburb; Postcode; State; Phone; Gender; Mark; Comment After you have entered the last record, close the form. You will be prompted to save. Since this was only a temporary table to use for data entry, click No. Open the table and you will see the new records listed.

1# Design Seasonal Greeting cards using MS-Power Point.

2# Design a AMU Magazine cover in MS-Power Point. Use the following:

i) Select a theme for the page, ii) Insert either a picture or clipart, and iii) Use WordArt.

1# Design a poster inviting all students of your department to the IT Fest (using MS-Power Point).

2# Create a 5-slide presentation on any topic. Use Images, Graphs, Chart, Tables, Animation, Time, Bullets, Transition, Sound, Hyperlink, Background template, Header and Footer (using MS-Power Point).

Field Name Data Type Field Size or Format ID Number Text 10 Name Text 15 Surname Text 15 Telephone Number Number Long Integer Date of Birth Date/Time Medium Date Stipend Currency Currency Foreigner Yes/No Yes/No

As

sig

nm

en

t

LAB – 6

Ac

tiv

itie

s

As

sig

nm

en

ts

Page 11: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 11

AM

U

AM

U

AM

U

AM

U

3# Create a website depicting different festivals of India. The Home page should have links of all festivals of India. It should also offer link to the other web pages and each of these web pages should contain a link to home page and to the various html pages required in your site. Use various effects to the images to be included in the website (using MS-Front Page/HTML Tags)

Page 12: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 12

AM

U

AM

U

AM

U

AM

U

WEEK #3 OBJECTIVE:

To learn the introduction of C++. To learn how to write basic C++ program and run it. To learn the constant and variables. To learn the concepts of operators used in C++. To learn the controls statements and loops. To learn the basic idea of object and class.

OUTCOMES: After completing this Lab, the students would be able to write, debug

and run a simple program in C++. They would learn to use the constant and variables and operators,

control statements and loops. They would also be able to learn idea of object and class.

Write a program in C++ to display your name, father’s name, course, Year on

to the computer screen without using classes and object. All information should be displayed in the separate line.

Write a menu driven program in C++ to perform all basic arithmetic operation addition, subtraction, multiplication, and division of two given values. Program receives two values and required operation to be performed from the keyboard and display particular result of the required operation.

Write a menu driven program in C++ that receives 4 digit integer value the keyboard and perform following operations 1. Reverse of that no. 2. Sum of number with its reverse

Ac

tiv

ity

A

ss

ign

me

nt

LAB – 8

Ac

tiv

ity

LAB – 7

Page 13: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 13

AM

U

AM

U

AM

U

AM

U

3. Sum of alternative digits (1 digit+3 digit and 2 digit+4 digit)

Write a menu driven program in C++ to receive integer number and convert equivalent binary, octal, hexadecimal number.

Write a menu driven program in C++ to perform all basic arithmetic operation addition, subtraction, multiplication, and division of two given values using function and switch case. Program receives two values and required operation to be performed from the keyboard and display particular result of the required operation.

Write a program in C++ to display mark sheet of the student. Define a class that contains data members to store student information line name, Branch, semester, marks in 6 different subjects, etc. Declare some member functions to get this information from the key board, to calculate result and to display all gathered information on to the computer screen in proper format.

As

sig

nm

en

t

LAB – 9

Ac

tiv

ity

A

ss

ign

me

nt

Page 14: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 14

AM

U

AM

U

AM

U

AM

U

WEEK #4 OBJECTIVE:

To learn the concept of arrays (1D and 2D) To learn the use of member functions and how we access

them.

OUTCOMES: In this week, the students would be able to handle arrays (1D and 2D)

and its associated operations. They would also be able to learn how can we access the member

functions of a class.

Write a menu driven program in C++ that performs the matrix manipulations such as Addition, Subtraction, Multiplication, Adjoint, and Inverse. The matrix class will have the appropriate member functions to perform these operations.

Write a class Time that will have the member functions to calculate the difference and addition for given two time values. It will store the time in hours, minutes and seconds and display the result in Days, Hours, Minutes, & Seconds.

Define a class employee. Include the following members: Data Members:

i) Name of the employee ii) Age of the employee

Member Functions:

LAB – 10

Ac

tiv

ity

A

ss

ign

me

nt

LAB – 11

Ac

tiv

ity

Page 15: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 15

AM

U

AM

U

AM

U

AM

U

i) To get the name and age of the employee ii) To display the name and age of the employee.

Define a class BankAccount to represent a bank account. Include the following members: Data Members:

i) Name of the depositor ii) Account Number iii) Type of account iv) Balance amount in the account

Member Functions: i) To assign initial value ii) To deposit an amount iii) To withdraw an amount after checking

Define a class employee having data members as emp_code, dept_code, age, basic, DA, HRA and three member functions as getdata(), putdata(), calculatesalary() to get, display all the values of data members and calculate the total salary by adding basic, DA, HRA. Write this program for 10(ten) employees using an array of objects. */

Write a Date Class that allows you to add, subtract, read and print simple dates of the form DD/MM/YY. Considering leap year calculations will be an added advantage.

As

sig

nm

en

t

LAB – 12

Ac

tiv

ity

A

ss

ign

me

nt

Page 16: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 16

AM

U

AM

U

AM

U

AM

U

WEEK #5 OBJECTIVE:

To learn the concept of Constructors, how would it be define and the types of constructors.

OUTCOMES: In this week, the students would be able to understand the concept of

constructor, its purpose, its characteristics, how many types of constructors.

W Write a program in C++ to demonstrate default constructor. Create a class having two data members in the private section. Define a default constructor to initialize these data members to initial value and display these values with the help of member function

Write a program in C++ to demonstrate parameterized/constructor overloading constructor. Create a class calculator that contains four data members in it. Initialize data members with different values using parameterized constructor and perform various arithmetic operation over these values and display result on to the computer screen.

Create a class called Triangle that stores the length of the base and height of

a right triangle in two private instance variables. Include a constructor that sets these values. Define two functions. The first is hypot( ), which returns the length of the hypotenuse. The second is area( ), which returns the area of the triangle.

LAB – 13

Ac

tiv

ity

A

ss

ign

me

nt

A

ct

ivit

y

LAB – 14

Page 17: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 17

AM

U

AM

U

AM

U

AM

U

Write a Clock class that simulates the keeping of time. Use three private class members: hours, minutes and seconds. Your class should be able to: Set() that starting time, Increment() the time by one second, Display() the time. The function should take an argument with a default value of zero to imply military time. If this value is something other than zero, display the time in standard AM and PM notation. For example, 4 minutes and 31 seconds past 7 PM should display either 19:04:31 or 07:04:31 OM and 5 minutes past midnight should be displayed as 00:05 or 00:05 AM.

Declare a class Number that contains two data member value1 and value2 of the type of integer, define constructor to give initial value, and perform addition, subtraction, multiplication and division of these two numbers using operating overloading of +,-,*,/ operator respectively [hint- binary operator overloading using member function]

Declare a class Number1 that contains two data member value1 and value2 of the type of integer, define constructor to give initial value, and perform addition, subtraction, multiplication and division of these two numbers using operating overloading of +,-,*,/ operator respectively [hint- binary operator overloading using friend function]

As

sig

nm

en

t

LAB – 15

As

sig

nm

en

t

LAB – 14

Ac

tiv

ity

Page 18: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 18

AM

U

AM

U

AM

U

AM

U

WEEK #6 OBJECTIVE:

To learn functions of object oriented programming. To learn the concept of Operator overloading. To learn how unary and binary operators are overloaded. To learn the type conversion.

OUTCOMES:

In this week, the students would be able to understand the features of object oriented programming.

They would be able to understand the concept of operator overloading. They would feel comfortable to overload binary operators. They would also be able to understand the type conversion.

Declare a class Number3 that contains a data member value of the type of

integer, define constructor to give initial value, and perform unary minus ,increment and decrement this number using operating overloading of -,++,-- operator respectively [hint- Unary operator overloading using member function]

Declare a class Number that contains a data member value of the type of integer, define constructor to give initial value, and perform unary minus, increment and decrement this number using operating overloading of -,++,-- operator respectively [hint- Unary operator overloading using friend function]

LAB – 16

Ac

tiv

ity

A

ss

ign

me

nt

Page 19: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 19

AM

U

AM

U

AM

U

AM

U

Define a class complex that contains two data member to store real and imaginary part of the complex number. Create a function to get values from the keyboard into these complex numbers, overload binary + and – to calculate addition and subtraction of two complex numbers respectively using member function.

Write a program to demonstrate explicit type conversion from basic type to user defined data type.

Write a program to demonstrate explicit type conversion from User Defined data type to Basic data type data type.

Write a program to demonstrate explicit type conversion from one user defined data type to another user defined data type.

LAB – 17

Ac

tiv

ity

A

ss

ign

me

nt

LAB – 18

As

sig

nm

en

t

Ac

tiv

ity

Page 20: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 20

AM

U

AM

U

AM

U

AM

U

WEEK #7 OBJECTIVE:

To learn the concept friend function. To learn the sorting techniques (Bubble, Selection &

Insertion).

OUTCOMES:

In this week, the students would be able to understand the working of friend function in the class and its purpose.

They would be able to understand the sorting techniques.

Write a program in C++ to calculate mean value of n numbers using friend function.

Write a menu driven program in C++ using class which will accepts an array of N integer values and sort them with any sorting technique of your choice (Bubble, Selection, and Insertion.)

Write a program in C++ to find greater between two numbers using friend function.

Ac

tiv

ity

LAB – 19

As

sig

nm

en

t

Ac

tiv

ity

#1

LAB – 20

Page 21: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 21

AM

U

AM

U

AM

U

AM

U

Write a program in C++ to display student’s information using friend function.

Write a program in C++ to swap between two numbers using friend function.

An election is contested by the five candidates. The candidates are

numbered from 1 to 5 and voting is done by accepting the candidate number from voter. Write a program which will accept the votes and count votes for each candidate. If the number typed by the voter is outside the range, the vote is discarded and the program will keep track of the number of such discarded votes. 31 Create a class A with some private data members and some public member function, now create a derived class B, that inherits A and having some data members and member functions its own, in main( ) function access attributes of base class with the help of derived class object to show inheritance concepts.

Create a class publication which has title of book and writers name. Create another class sales which accounts no. of sales for every month (upto 3 months) and then calculate total sales.

Ac

tiv

ity

LAB – 21

As

sig

nm

en

t

Ac

tiv

ity

#2

A

ss

ign

me

nt

Page 22: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 22

AM

U

AM

U

AM

U

AM

U

WEEK #8

OBJECTIVE:

To learn the concept Inheritance and their types/levels. To learn the concept of virtual class and function. To learn ‘this’ pointer and its use.

OUTCOMES:

In this week, the students would be able to understand the inheritance and its type.

They would be able to understand the virtual function and virtual classes.

They would be able to use ‘this’ pointer.

Write a program to demonstrate the following:

Write a program to demonstrate the following:

Staff

Officer

Officer

Non-Teaching Teaching

Regular Temporary

Exam

Student

Person

Result

Sports

LAB – 22

Ac

tiv

ity

A

ss

ign

me

nt

Page 23: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 23

AM

U

AM

U

AM

U

AM

U

Write a program to solve the ambiguity problem in inheritance where two

different classes are inherited from single base class and a new class is derived from these two derived classes. How this problem is solved with the help of virtual base class concept.

Write a program to use ‘this’ pointer to find elder from two person. Define a class Person to store age of the person. Define constructor/member function to give initial value to the data member age. And then define a function elder to compare ages of two different persons using this pointer to find out the elder person.

Write a program to show how member of the class are accessed through the

pointer to class using arrow operator (->).

Write a program to show the concept of virtual function with the help of suitable programming example.

LAB – 23

Ac

tiv

ity

A

ss

ign

me

nt

LAB – 24

Ac

tiv

ity

A

ss

ign

me

nt

Page 24: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 24

AM

U

AM

U

AM

U

AM

U

WEEK #9

OBJECTIVE:

To learn the applications of inheritance and virtual functions.

To learn the command line arguments.

OUTCOMES:

In this week, the students would be able to feel comfortable with the heritance and virtual functions.

They would be able to understand the command line arguments.

Create a simple “shape” hierarchy: a base class called Shape and derived classes called Circle, Square, and Triangle. In the base class, make a virtual function called draw( ),and override this in the derived classes. Make an array of pointers to Shape objects that you create on the heap (and thus perform upcasting of the pointers), and call draw( ) through the base-class pointers, to verify the behaviour of the virtual function. If your debugger supports it, single-step through the code.

Modify the previous Exercise to draw( ) is a pure virtual function. Try creating an object of typeShape. Try to call the pure virtual function inside the constructor and see what happens. Leaving it as a pure virtual, give draw( ) a definition.

Write a small program to show the difference between calling a virtual

function inside a normal member function and calling a virtual function inside a constructor. The program should prove that the two calls produce different results.

LAB – 25

Ac

tiv

ity

A

ss

ign

me

nt

LAB – 26

Ac

tiv

ity

Page 25: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 25

AM

U

AM

U

AM

U

AM

U

Write a program that emulates the DOS COPY command. That is, it should copy the contents of a text file (such as any .CPP file) to another file. Invoke the program with two command-line arguments—the source file and the destination file—like this: C>copy srcfile.cpp destfile.cpp In the program, check that the user has typed the correct number of command line arguments, and that the files specified can be opened.

Write a program to check whether the arithmetic expression is properly parenthesized using the concept of stack.

Write a program to convert any arithmetic expression from infix to postfix notation using the concept of stack.

As

sig

nm

en

t

As

sig

nm

en

t

Ac

tiv

ity

LAB – 27

Page 26: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 26

AM

U

AM

U

AM

U

AM

U

WEEK #10

OBJECTIVE:

To learn the concept of Stacks and their applications.

OUTCOMES:

In this week, the students would be able to understand the Stack, its associated operations and their applications.

Write a program to add and multiply two polynomials with integer coefficients.

Write a program to evaluate arithmetic expression in the postfix notation using the concept of stack.

Sometimes a program requires two stacks containing the same type of item. If the two stacks are stored in separate arrays. Then one stack might overflow while there was considerable unused space in the other. A neat way to avoid the problem is to pull all the space in one array and let one stack grow from one end of the array and other stack start at the other end and grow in opposite direction i.e. towards the first stack, in this way, if one stack turns out to be large and the other small, then they will still both fit, and there will be no overflow until all the space is actually used. Declare a new data structure type Double Stack that includes the array and the two

LAB – 28

Ac

tiv

ity

LAB – 29

Ac

tiv

ity

LAB – 30

Ac

tiv

ity

Page 27: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 27

AM

U

AM

U

AM

U

AM

U

indices top A and top B, and write functions Push A, Push B, Pop A and Pop B to handle the two stacks within one Double Stack.

Write a program with appropriate functions to develop the following: a) Empty one stack onto the top of another stack. b) Move all the items from a queue onto a stack. c) Start with a queue and an empty stack, and use the stack to reverse the

order of all the items in the queue.

As

sig

nm

en

t

Page 28: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 28

AM

U

AM

U

AM

U

AM

U

WEEK #11 OBJECTIVE:

To learn the concept of Queue, Dequeue and its applications.

To learn the concept of file handling. To learn the concept of Exception Handling.

OUTCOMES:

In this week, the students would be able to understand the Queue and its associated operations.

They would be able to understand the Dequeue and its applications.

They would be able to understand the file handling They would also be able to understand the exception handling.

Write a program to multiply two spares matrices.

In a loop, prompt the user to enter name data consisting of a first name, middle initial, last name, and employee number (type unsigned long). Then, using formatted I/O with the insertion (<<) operator, write these four data items to an ofstream object. Don’t forget that strings must be terminated with a space or other whitespace character. When the user indicates that no more name data will be entered, close the ofstream object, open an ifstream object, read and display all the data in the file, and terminate the program.

LAB – 31

Ac

tiv

ity

A

ss

ign

me

nt

Page 29: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 29

AM

U

AM

U

AM

U

AM

U

Write a C++ program to implement queues in a circular array with one

unused entry in the array. That is, we consider that the array is full when the rear is two positions before the front; when the rear is one position before, it will always indicate an empty queue.

Do the following operations on a given list. a) Write a function that deletes the last entry of a list. b) Write a function that deletes the first entry of a list. c) Write a function that reverse the order of the entries in a list. d) Write a function that splits a lists into other lists, so that the entries that

were in odd-numbered positions are now in one list (in the same relative order as before) and those from even numbered positions are in the new list.

The world DEQUE is a shortened form of a Double Ended Queue and denotes a list in which items can be added or deleted from either the first or the last position of the list, but no changes can be made elsewhere in the list. Thus a DEQUE is a generalization of both a stack and queue.

Create a class with a main( ) that throws an object of class Exception inside a try block. Give the constructor for Exception a String argument. Catch the exception inside a catch clause and print the String argument. Add a finally clause and print a message to prove you were there.

Let Stack_ptr be a pointer to tack of integers and item be an integer variable. Write member functions like Push(), Pop(), Initialize(), Empty() and Full() for doing the following tasks. [You may declare additional variable in your functions is needed] a) Return the top element of the stack and leave the top element unchanged.

If the stack is empty, return INT_MAX. b) Return the third element from the top of the stack, provided that stack

contains at least three integers. If not, return INT_MAX. Leave the stack unchanged.

c) Return the bottom element of the stack (or INT_MAX if stack empty), and leave the stack unchanged.

d) Delete all occurrences of X from the stack, leaving the other elements of the stack in the same order.

LAB – 32

Ac

tiv

ity

A

ss

ign

me

nt

LAB – 33

Ac

tiv

ity

A

ss

ign

me

nt

Page 30: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 30

AM

U

AM

U

AM

U

AM

U

WEEK #12 OBJECTIVE:

To learn practical use of Object Oriented Approach.

OUTCOMES:

In this week, the students would be able to implement the different object oriented programming approach in the real life applications.

This exercise involves developing a very simple room booking system. The

rooms have the following attributes: name, area, number of doors, and address. The location is given in terms of two dimensional coordinates (X, Y) of the center of the room. For example, the room description is as following: Name Area X Y Room1 902 100 250 1. Write a program for an online room booking system. The program

should have capability to add new room to the system. 2. Read the room details from the file “ROOM.txt” and add to the

system using the add functionality. You can assume maximum number of rooms to be 1000.

3. Extend the system to add Labs which have the following attributes: name, area, number of doors, location (X, Y), and number of computers. Read the lab details from the file “LAB.txt” and add to the system.

4. Further extend the system to have lecture halls with the following attributes: name, area, number of doors, location (X, Y), number of chairs. Read the details from the file “LEC.txt” and add to the system.

The developed system should implement the following functionalities: 1. The program should be able to add rooms, labs, or lecture halls to the

system dynamically. 2. The program should be able to remove a room, lab, or lecture hall

from the system. 3. The program should have a mechanism to book a room, lab, or

lecture hall. 4. A person needs 30 units of the area to sleep in a room. The program

should give the minimum number of rooms required to accommodate given number of persons.

5. The program should be able to find the smallest lecture hall that can accommodate the given number of students. [use chair information].

LAB – 34-35-36

As

sig

nm

en

t

Page 31: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 31

AM

U

AM

U

AM

U

AM

U

6. The program should find the lab with least equipment density (computers per area unit) and should be able to add new equipment to the system [increasing the number of equipments is sufficient].

7. Find a room nearest to the given location. 8. Mechanism to book or un-book a room, lab, and lecture hall. 9. Program should be able to print all details of the given room, lab, and

lecture hall. 10. When you exit the program, the system must store current booking

status in text file. The text file is loaded back to memory when the program starts again.

Hint: The students should use the following C++ features at least once in the code: Function Overloading Operator overloading Constructors and destructors Inheritance Virtual Functions Dynamic Memory Allocation Function Templates Access Specifiers

You are allowed to add new functionalities to the system to use these features.

Page 32: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 32

AM

U

AM

U

AM

U

AM

U

WEEK #13 OBJECTIVE:

To learn more about exception handling.

OUTCOMES:

In this week, the students would be able to handling the different types of exceptions occurred in their programming.

Create your own exception class using the extends keyword. Write a constructor for this class that takes a String argument and stores it inside the object with a String reference. Write a method that prints out the stored String. Create a try-catch clause to exercise your new exception.

Write a class with a method that throws an exception of the type created in previous Exercise. Try compiling it without an exception specification to see what the compiler says. Add the appropriate exception specification. Try out your class and its exception inside a try-catch clause.

Define an object reference and initialize it to null. Try to call a method through this reference. Now wrap the code in a try-catch clause to catch the exception.

LAB – 37-38

Ac

tiv

ity

A

ss

ign

me

nt

LAB –39

Ac

tiv

ity

Page 33: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 33

AM

U

AM

U

AM

U

AM

U

Create a class with two methods, f( ) and g( ). In g( ), throw an exception of a new type that you define. In f( ), call g( ), catch its exception and, in the catch clause, throw a different exception (of a second type that you define). Test your code in main( ).

As

sig

nm

en

t

Page 34: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 34

AM

U

AM

U

AM

U

AM

U

WEEK #14 OBJECTIVE:

To learn the concept of Linked List, its types and associated operations.

To learn the concepts of Queue.

OUTCOMES:

In this week, the students would be able to create, traverse and other associated operations of a Linked List.

They would be able to implement Queue using linked list.

Write a C++ program that will concatenate two circular linked lists,

producing one circular linked list and again split it into two lists.

Write a menu driven program to implementing the various operations on a Queue represented using a linked list.

Write a C++ program for manipulating a doubly linked list as follows: a) Add a node after a particular node. b) Add a node before a particular node. c) Delete a particular node. d) Traverse the list.

LAB – 40

Ac

tiv

ity

A

ss

ign

me

nt

LAB – 41-42

Ac

tiv

ity

Page 35: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 35

AM

U

AM

U

AM

U

AM

U

WEEK #15 OBJECTIVE:

To learn the concept of Binary Search Tree and its associated operations.

To learn the different traversal of a Binary Search Tree.

OUTCOMES:

In this week, the students would be able to understand the Binary Search Tree and its associated operations.

They would be able to understand and find out different tree traversal order.

Write a menu driven program to implement the different operations like

insert node, pre-order traversal, in-order traversal, post-order traversal, delete node, total nodes, total external nodes, total internal node, height, smallest node, largest node, mirror images etc. in a Binary Search Tree.

LAB – 43-44-45

Ac

tiv

ity

Page 36: Laboratory Manual · 1. The students must complete the weekly assignments well in activities/ time (i.e., within the same week). 2. The students must maintain the of their completed

LAB MANUAL/CSM-11P1/DoCS-AMU Page 36

AM

U

AM

U

AM

U

AM

U

WEEK #16 OBJECTIVE:

To learn the concept of Threaded Binary Search Tree and its associated operations.

To learn the different traversal of a Threaded Binary Search Tree.

To learn the concepts of Graph and its traversal.

OUTCOMES:

In this week, the students would be able to understand the Threaded Binary Search Tree and its associated operations.

They would be able to understand and find out different tree traversal order.

They would be able to understand the graph and its traversal techniques.

Write a menu driven program to implement the different operations like in-order traversal, insertion, deletion on a Threaded Binary Search Tree.

Write a program to traverse a graph using BFS and DFS techniques.

LAB – 46

Ac

tiv

ity

LAB – 47-48

Ac

tiv

ity