0% found this document useful (0 votes)
379 views41 pages

OOPs in C++ Lab Manual - 0

Uploaded by

TRUE LOVERS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
379 views41 pages

OOPs in C++ Lab Manual - 0

Uploaded by

TRUE LOVERS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

Laboratory Manual

(Version 10.0)
for

Object Oriented Programming in


C++-Lab
(MCA-154)
MCA - II Semester
Compiled by:

Dr. Ritika Wason


(Associate Professor, BVICAM, New Delhi)
Mrs. Manu Anand
(Assistant Professor, BVICAM, New Delhi)

Bharati Vidyapeeth’s
Institute of Computer Applications
and Management (BVICAM)
A-4, Paschim Vihar, Rohtak Road, New Delhi-63
Visit us at: www.bvicam.in
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

Index
List of Abbreviations

Declaration

1. Vision of the Department 1

2. Mission of the Department 2

3. Programme Educational Objectives (PEOs) 3

4. Programme Outcomes (POs) 4

5. Institutional Policy for Students’ Conduct 5

6. Learning Outcomes of Laboratory Work 6

7. Course/Lab Outcomes (COs) 6

8. Mapping of COs with POs 7

9. Course/Lab Description 8

10. Grading Policy 9

11. Lesson Plan 10

12. Assignments 11

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │ Page 2 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

List of Abbreviations
BTL Bloom’s Taxonomy Level

CE Communication Efficacy

CICP Conduct Investigations of Complex Computing Problems

CK Computational Knowledge

CO Course Outcome

DAC Departmental Advisory Committee

DDS Design and Development of Solutions

IDE Integrated Development Envoirnment

I&E Innovation and Entrepreneurship

I&T Individual & Team Work

IQAC Internal Quality Assurance Cell

LLL Life-Long Learning

MTU Modern Tool Usage

OOP Object Oriented Programming

PA Problem Analysis

PE Professional Ethics

PEO Programme Educational Objective

PMF Project Management and Finance

PO Programme Outcome

SEC Societal and Envoirnmental Concern

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │Page 3 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

Declaration
Department : Department of Computer Science and
Applications

Course, Year and the : MCA - I Year, II Semester


Semester to which Lab is
offered

Name of the Lab Course : Object Oriented Programming in C++ Lab.

Course Code : MCA-154

Version No. : 10.0

Name of Course/Lab : Dr. Ritika Wason & Mrs. Manu Anand


Teacher

Laboratory Manual : 1. Mrs. Vaishali Joshi, Chairperson


Committee
2. Dr. Anupam Baliyan, Member

3. Dr. Ritika Wason, Member

4. Mrs. Tanya Pathak Garg, Member

5. Mr. Uttam Singh Bist, Member

6. Prof. P. S. Grover, Margdarshak

7. Mr. Amit Sharma, Alumni & Industry Expert

8. Dr. Ritika Wason, Concerned Subject Teacher,


Convener

Approved by : DAC Date: 02/12/2019

Approved by : IQAC Date: 07/12/2019

Signature Signature Signature


(Course Teacher) (Head of Department) (IQAC Coordinator)

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │ Page 4 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

1. Vision of the Department


To become a Centre of excellence in the field of Computer Science and
Applications, to contribute effectively in the rapidly changing global economy
directed towards national development ensuring prosperity for the mankind.

2. Mission of the Department


M1 To become a centre of excellence in the field of Computer Science and
Applications and produce professionals as per global industry standards.

M2 To foster innovation, entrepreneurial skills, research capabilities and


bring all-round development amongst budding professionals.

M3 To promote analytical and collaborative life-long learning skills, among


students and faculty members involving all stakeholders.

M4 To inculcate strong ethical values and professional behaviour while


giving equal emphasis to social commitment and nation building.

3. Programme Educational Outcomes (PEOs)


The PEO’s for the MCA programme are as follows:

PEO1 Exhibit professional competencies and knowledge for being a successful


technocrat.

PEO2 Adopt creative and innovative practices to solve real-life complex


problems.

PEO3 Be a lifelong learner and contribute effectively to the betterment of the


society.

PEO4 Be effective and inspiring leader for fellow professionals and face the
challenges of the rapidly changing multi-dimensional, contemporary
world.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │Page 5 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

4. Programme Outcomes (POs)


PO1: Computational Knowledge (CK)
Demonstrate competencies in fundamentals of computing, computing
specialisation, mathematics, and domain knowledge suitable for the
computing specialisation to the abstraction and conceptualisation of
computing models from defined problems and requirements.

PO2: Problem Analysis (PA)


Identify, formulate, and analyze complex real-life problems in order to
arrive at computationally viable conclusions using fundamentals of
mathematics, computer sciences, management and relevant domain
disciplines.

PO3: Design and Development of Solutions (DDS)


Design efficient solutions for complex, real-world problems to design
systems, components or processes that meet the specifications with
suitable consideration to public health, and safety, cultural, societal, and
environmental considerations.

PO4: Conduct Investigations of Complex Computing Problems (CICP)


Ability to research, analyze and investigate complex computing problems
through design of experiments, analysis and interpretation of data, and
synthesis of the information to arrive at valid conclusions.

PO5: Modern Tool Usage (MTU)


Create, select, adapt and apply appropriate technologies and tools to a
wide range of computational activities while understanding their
limitations.

PO6: Professional Ethics (PE)


Ability to perform professional practices in an ethical way, keeping in
mind cyber regulations & laws, responsibilities, and norms of
professional computing practices.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │ Page 6 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

PO7: Life-Long Learning (LLL)


Ability to engage in independent learning for continuous self-
development as a computing professional.

PO8: Project Management and Finance (PMF)


Ability to apply knowledge and understanding of the computing and
management principles and apply these to one’s own work, as a member
and leader in a team, to manage projects in multidisciplinary
environments.

PO9: Communication Efficacy (CE)


Ability to effectively communicate with the technical community, and
with society at large, about complex computing activities by being able to
understand and write effective reports, design documentation, make
effective presentations, with the capability of giving and taking clear
instructions.

PO10: Societal and Envoirnmental Concern (SEC)


Ability to recognize and assess societal, environmental, health, safety,
legal, and cultural issues within local and global contexts, and the
consequential responsibilities applicable to professional computing
practices.

PO11: Individual & Team Work (I&T)


Ability to work in multi-disciplinary team collaboration both as a
member and leader as per need.

PO12: Innovation and Entrepreneurship (I&E)


Ability to apply innovation to track a suitable opportunity to create value
and wealth for the betterment of the individual and society at large.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │Page 7 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

5. Institutional Policy for Students’ Conduct


The following guidelines shall be followed:-

5.1 All the students in their introductory Lab. shall be assigned a system, which
shall be their workplace for the complete semester. Students can store
records of all their Lab. assignments on their individual workstations.

5.2 Introductory Lab. shall include an introduction to the appropriate


software/tool, followed by a basic Introductory Assignment having Practice
Questions. All the students are expected to complete this assignment within
a week time, as the same shall be assessed through a lab. test.

5.3 Each week the instructor, in parallel to respective topics covered in the
theory lecture, shall assign a set of practical problems to the students in form
of Assignments (A, B, C, .....). The problems in these assignments shall be
divided into two parts. The first set of Problems shall be compulsory for all
the students and its record need to be maintained in the Prcatical File,
having prescribed format, as given in Appendix-A. All the students should
get the weekly assigntment checked and signed in the Practical File by the
respective teacher in the immediate succeeding week. The second set of
problems is Advanced Problems and shall be optional. Student may solve
these advanced problems for their further practice.

5.4 Cellular phones, pagers, CD players, radios and similar devices are
prohibited in the classrooms, laboratories and examination halls.

5.5 Laptop-size computers / Tablets may be used in lectures for the purpose of
taking notes or working on team-projects.

5.6 The internal practical exam shall be conducted towards the end of the
semester and shall include the complete set of Lab exercises conducted as
syllabus. However, students shall be assessed on continuos basis through
overall performances in regular lab. tests, both announced and surprise and
viva-voce.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │ Page 8 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

5.7 The respective faculty shall prepare and submit sufficient number of
practical sets of computing problems to the Dean (Examinations), atleast two
weeks prior to the actual exam. It is the responsibility of the faculty to
ensure that a set should not be repeated for more than 5 students in a given
batch.

5.8 The exam shall be of 3 hours duration where the student shall be expected to
implement solutions to his/her assigned set of problems on appropriate
software tools in the lab.

5.9 Once implemented, student shall also appropriately document code


implemented in the assigned answer sheets, which shall be submitted at the
end of the examination. All the students shall also appear for viva-voce
examination during the exam.

5.10 Co-operate, Collaborate and Explore for the best individual learning
outcomes but copying or entering into the act of plagiarism is strictly
prohibited.

6. Learning Outcomes of Laboratory Work


The student shall demonstrate the ability to:

 Verify and Implement the concepts and theory learnt in class.

 Code and use Software Tools to solve problems and present their optimal
solutions.

 Apply numerical/statistical formulas for solving problems/questions.

 Develop and apply critical thinking skills.

 Design and present Lab as well as project reports.

 Apply appropriate methods for the analysis of raw data.

 Perform logical troubleshooting as and when required.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │Page 9 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

 Work effectively as a member of a team in varying roles as need be.

 Communicate effectively, both oral and written.

 Cultivate ethics, social empathy, creativity and entrepreneurial mindset.

7. Course/Lab Outcomes (COs)


CO1 Acquire the skills for writing a program in different C++ Integrated Development
Environments (IDE).(BTL3)

CO2 Implement polymorphic features of object-oriented programming in creating and


extending abstract data types.(BTL3)

CO3 Dissect real-world problems using reusable classes with inheritance, exception
handling and file handling, etc.(BTL4)

CO4 Create efficient programs using generic and STL programming for generating
optimized code. (BTL6)

CO5 Work in teams to develop project for real-life cases using object-oriented features.
(BTL6)

8. Mapping of CO’s with PO’s


Table 1: Mapping of CO’s with PO’s

PO/CO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12

CO1 3 3 3 - 3 3 - - - 2 - -

CO2 3 3 3 2 - 3 - - - 2 - -

CO3 3 3 3 3 - 3 2 - 1 - 2 -

CO4 3 3 3 3 - 3 - - 2 - - -

CO5 3 3 3 3 3 3 3 2 3 3 3 2

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │ Page 10 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

9. Course/Lab Description
Course (Lab) Title : Object Oriented Programming in C++ Lab.

Course (Lab) Code : MCA-154

Credits : 02

Pre-requisites : Knowledge of Microsoft Visual Studio IDE, basics of


mathematics, basic logic building skills, basics of data
structure

Academic Session : January to June

Contact Hours/Week : 04 (02 Labs of 02 hours each/Week)

Internal Assessment : 40 Marks

External Assessment : 60 Marks

10. Grading Policy


Item Points Marks Remarks

Weekly Lab Assignments 10 10 Closed Book/Open Book


including Practical Files
Internal End-Term Practical 20 10 Closed Book
Examination
Viva-Voce 10 10 Closed Book

Project 10 10 Innovative Applications of


Programming
External End-Term 60 60 Closed Book (conducted and
Examinations evaluated by the University)
Total 100

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │Page 11 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

11. Lesson Plan


Week Lab Topics / Concepts to be Covered Assignment No.
No. No.

1. 1. Introduction to Microsoft Visual C++, Basic Assignment A,


Structure of a C++ program, cin, cout, variables Problems [AP1-AP7]
and operators.

2. Basic constructs of C++ programming (datatypes, Assignment A, ,


variables, operators etc) along with valid Advanced Problems
expressions for problem solving. [AA1-AA4]

2. 3. Modular programming through Functions Assignment B,


Problems [BP1-BP7]

4. Modular programming through Functions Assignment B,


Advanced Problems
[BA1-BA3]

3. 5. Arrays, Manipulators and utility Functions Assignment C,


Problems [CP1-CP7]

6. Structures and Enums Assignment C,


Advanced Problems
[CA1-CA3]

4. 7. Buffer Reserved for Revision Assignment A-C

8. Typeless Pointers, Classes and Object Assignment D,


Problems [DP1-DP7]

5. 9. Class Creation through constructors and Assignment D,


destructors Advanced Problems
[DA1-DA4]

10. String Handling with Overloading and Assignment E,


Inheritance as required Problems [EP1-EP7]

6. 11. String Handling with Overloading and Assignment E,


Inheritance as required Advanced Problems
[EA1-EA5]

12. Buffer Reserved for Revision Assignement D-E

7. 13. Operator Overloading Assignment F,


Problems [FP1-FP6]

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │ Page 12 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

Week Lab Topics / Concepts to be Covered Assignment No.


No. No.

14. Operator Overloading Assignment F,


Advanced Problems
[FA1-FA6]

8. 15. Inheritance with Overloading Assignment G,


Problems [GP1-GP6]

16. Inheritance with Overloading Assignment G,


Advanced Problems
[GA1-GA2]

9. 17. Containership and file Handling Assignment H,


Problems [HP1-HP6]

18. File Manipulation Assignment H,


Advanced Problems
[HA1-HA4]

10. 19. Exception Handling Assignment I,


Problems [IP1-IP5]

20. Exception Handling Assignment I,


Advanced Problems
[IA1-IA3]

11. 21. Buffer Reserved for Revision Assignemnt F-I

22. Generic Programming and STL Assignment J,


Problems [JP1-JP4]

12. 23. Generic Programming and STL Assignment J,


Problems [JP5-JP7]

24. Generic Programming and STL Assignment J,


Advanced Problems
[JA1-JA4]

13. 25 Buffer Reserved for Revision

26. Buffer Reserved for Revision

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │Page 13 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

12. Assignments
Assignment Set: A

Objectives of the Assignment:


• Familiarize with syntax and structure of C++-programming on
Microsoft Visual Studio C++ IDE.
• Familiarize with problem solving using basic constructs of C++
Programming.
• Test and execute the programs and correct syntax and logical
errors

CO/BTLCovered: CO1/BTL2 & BTL3


Problems:
AP1 Design a solution called greeting.cpp that asks the username and
greets the user with a personalized greeting.

AP2 Develop a solution to calculate the weekly development billing


report for the biggest client of a local radio station “Aapka FM”.
Aapka FM has been in operation for over 10 years and a car
dealership is its biggest client. Alex has recently taken over as
general manager of the radio station. The station has a format for
regional and bollywood music and uses the following rate
structure for car dealership account: Production: Rs. 1000 /hr Pre-
production: Rs. 250/hr Producer’s Fee: Rs. 200/hr Design a
solution to calculate weekly development billing report for the
above said car dealership.

AP3 Design a solution to accept two integers from the user. Compose
appropriate functions to add, subtract, multiply and divide these
two input numbers.

AP4 Design a solution to find the smallest no out of 2 inputs using cin
and cout.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │ Page 14 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

AP5 Write a program in C++ to read the values of a, b and c and


display the value of x where x = a / b –c

Test your program for the following values:

(a) a = 250, b= 85, c= 25

(b) a=300, b=70, c = 70

AP6 Design functions to check if a number entered by the user is even


or odd using:

i. Ternary Operator

ii. Bitwise Operator

AP7 Create code called revenue.cpp to compute Installation revenue for


a cable installer. Ask the user to input the number of installations
(yards of cable installed). The program should calculate the total
revenue payable from these installations using the formula:

installRevenue = INSTALL_CHARGE * installation

Advanced Problems:
AA1 Write a generic program to print star pattern. Your solution should
ask the user how many stars do they want to print and whether
they want to print it diagonal or hexagonal.
AA2 Write a program that calculates how much money you’ll end up
with if you invest an amount of money at a fixed interest rate,
compounded yearly. Have the user furnish the initial amount, the
number of years, and the yearly interest rate in percent.
AA3 Suppose you give a dinner party for six guests, but your table seats
only four. In how many ways can four of the six guests arrange
themselves at the table? Any of the six guests can sit in the first
chair. Any of the remaining five can sit in the second chair. Any of
the remaining four can sit in the third chair, and any of the

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │Page 15 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

remaining three can sit in the fourth chair. (The last two will have
to stand.) So the number of possible arrangements of six guests in
four chairs is 6*5*4*3, which is 360. Design a program that
calculates the number of possible arrangements for any number of
guests and any number of chairs. (Assume there will never be
fewer guests than chairs.) Don’t let this get too complicated. A
simple for loop should do it.
AA4 Create the equivalent of a four-function calculator. The program
should ask the user to enter a number, an operator, and another
number. (Use floating point.) It should then carry out the specified
arithmetical operation: adding, subtracting, multiplying, or
dividing the two numbers. Use a switch statement to select the
operation. Finally, display the result. When it finishes the
calculation, the program should ask whether the user wants to do
another calculation. The response can be ‘y’ or ‘n’. Some sample
interaction with the program might look like this: Enter first
number, operator, second number: 10 / 3 Answer = 3.333333 Do
another (y/n)? y Enter first number, operator, second number: 12 +
100 Answer = 112 Do another (y/n)? n
Assignment Set: B

Objectives of the Assignment:


• Familiarize with problem solving using basic constructs of C++
Programming.
• Examine appropriate usage of datatypes, variables and
operators.
• Decompose a problem into functions and synthesize a complete
program using divide and conquer approach.

CO/BTLCovered: CO1/BTL2 & BTL3


Problems:
BP1 Design a program to find size of all fundamental data types in C++.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │ Page 16 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

BP2 Design and develop a program in C++ to print a mystery series


from 1 to 50.

The series are:

5 4 2 7 11 10 8 13 17 16 14 19 23 22 20 25 29 28 26 31 35 34 32
37 41 40 38 43 47 46 44 49

The algorithm depicted below may be followed:

BP3 Design and develop a program in C++ to print the code (ASCII
code / Unicode code etc.) of a given character.

BP4 Design a C++ program to swap first and last digits of any number.

BP5 Design a program to count the total number of digits in a number


input by the user from the keyboard.

BP6 Define a c function that perform a logical XOR operation using the
logical operators AND (&&), OR (||) and NOT (!).

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │Page 17 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

BP7 Print the following pattern:


1
232
34543
4567654
567898765

Advanced Problems:

BA1 Interpolate the function f( x ) = x^3 over the range from -1.0 to 4.0
in steps of 0.5, using three approaches:
• Constant - Take the average of the inputs at the end points,
evaluate f( average input ), and assume the function is
constant over the range.
• Linear - Evaluate the function at the endpoints, and then use
a linear interpolation of the endpoint function values in
between.
• Non-Linear - Linearly interpolate the function inputs over
the range, and at each evaulation point, evaluate the
function of the interpolated inputs

BA2 Design and develop a C++ program to which reads an given


integer n and prints a twin prime which has the maximum size
among twin primes less than or equals to n.

According to wikipedia "A twin prime is a prime number that is


either 2 less or 2 more than another prime number—for example,
either member of the twin prime pair (41, 43). In other words, a
twin prime is a prime that has a prime gap of two".

BA3 Print the following pattern:

i.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │ Page 18 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

ii.

iii.

iv.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │Page 19 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

Assignment Set: C

Objectives of the Assignment:


• Familiarize with problem solving using user-defined datatypes
of C Programming in C++.
• Create and Implement effective data handling through arrays.
• Master the use of manipulators and utility functions.

CO/BTLCovered: CO1 & CO2/BTL2 & BTL3


Problems:
CP1 Design a C++ program to implement Fibonacci series using arrays?

CP2 An electricity board charges the following rates to domestic users


to discourage large consumption of energy.

For first 100 units Rs 1.50 /unit

For the next 200 units rs 3.00/unit

Beyond 300 units Rs. 5.00/unit

All users are charged a minimum of rs .100. If the total cost exceeds
rs. 250, then an additional surcharge of 15% is added. Design and
develop a program to read the names of users and number of units
consumed and print out the charges with names.

CP3 Design a program to generate random alphabets and store them in


a character array.

CP4 Design and develop a solution to convert a decimal number


entered by user into its hexadecimal, octal equivalent using
manipulators

CP5 Three floating-point arrays are used to store marks secured by


students in three class tests. The final marks secured by a student
are to be calculated as the average of best-two. Write a program
that calculates the final marks and stores them in another array

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │ Page 20 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

Results.

CP6 Modify the above program so that the individual marks are stored
in a 2D array, rather than three independent 1D arrays.

CP7 Eyes are one of the most beautiful and expressive components to
the human body. eye color is all dependent on your genetic
makeup, but psychologists have in fact connected certain colors of
the eye back to personality traits. Develop an interesting solution to
ask the user his eye color and tell them their personality traits on
basis of the same. Blue eyes–It is said that most people with blue
eyes are attractive, in addition to having a very calm and peaceful
personality. Blue eyes are also representative of knowledge. Brown
eyes– People who don this hue are said to be very independent,
self-confident and determined. You are known to be trustworthy,
and when people look at you they get a sense of security and
stability. Green eyes–People with green eyes are curious about
nature, very passionate in their relationships with other people and
have an overall positive and creative outlook on life. These people
tend to get jealous easily, but possess large amounts of love. Hazel
eyes–People with hazel eyes are spontaneous and will rarely back
down from a challenge. If there is more green mixed into your
eyes, you like to be mischievous. If you have more brown mixed in,
you are more approachable to other people. Hazel eyes are special
because they seem to change color depending on your mood. Black
eyes– People with black eyes are known to be very secretive and
keep to themselves around new faces until they feel comfortable.
They are very passionate and loyal, especially to their friends.
People with black eyes are also very intuitive and have the ability
to tap into powerful energy. Gray eyes– If you have gray eyes, you
are known to be very wise and gentile. These people are sensitive,
but have a strong inner strength and think analytically. They can
also very easily change their mood to suit any situation at hand.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │Page 21 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

Develop the above solution as an interactive game, where once the


user enters his eye color they are shown a personality trait and
asked if it matches them or not. (Hint: Use concept of
Enumerations)

Advanced Questions:

CA1 Apply 2-D arrays to create a (10, 7) table where field width =6 and
each cell contains the product of the row and column as a value.

CA2 A point on the two-dimensional plane can be represented by two


numbers: an x coordinate and a y coordinate. For example, (4,5)
represents a point 4 units to the right of the vertical axis,and 5 units
up from the horizontal axis. The sum of two points can be defined
as a new point whose x coordinate is the sum of the x coordinates
of the two points, and whose y coordinate is the sum of the y
coordinates. Write a program that uses a structure called point to
model a point. Define three points, and have the user input values
to two of them. Then set the third point equal to the sum of the
other two, and display the value of the new point. Interaction with
the program might look like this: Enter coordinates for p1: 3 4 Enter
coordinates for p2: 5 7 Coordinates of p1+p2 are: 8, 11

CA3 We said earlier that C++ I/O statements don’t automatically


understand the data types of enumerations. Instead, the (>>) and
(<<) operators think of such variables simply as integers. You can
overcome this limitation by using switch statements to translate
between the user’s way of expressing an enumerated variable and
the actual values of the enumerated variable. For example, imagine
an enumerated type with values that indicate an employee type
within an organization: enum etype { laborer, secretary, manager,
accountant, executive, researcher }; Write a program that first
allows the user to specify a type by entering its first letter (‘l’, ‘s’,
‘m’, and so on), then stores the type chosen as a value of a variable
of type enum etype, and finally displays the complete word for this

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │ Page 22 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

type. Enter employee type (first letter only) laborer, secretary,


manager, accountant, executive, researcher): a Employee type is
accountant. You’ll probably need two switch statements: one for
input and one for output.

Assignment Set: D

Objectives of the Assignment:


• Familiarize with the usage Typeless Pointers, pass by value,
pass by pointer and pass by reference.
• Create and Implement effective data handling through strings.
• Apply constructors, destructors and inheritance for effective
object creation and manipulation.

CO/BTLCovered: CO1 & CO2/BTL2 & BTL3


Problems:
DP1 Design and develop a function to display the address and values of
all array elements through a typeless pointer.

DP2 Design a simple simulation in C++ to evaluate the efficiency of a


solution that displays square of the number entered by the user.
Design the solution using pass by value, pass by pointer and pass
by reference.

DP3 Design a program using static data member to keep track of count
of object created and destroyed.

DP4 Create a Message class with a constructor that takes a single string
with a default value. Create a private member string, and in the
constructor simply assign the argument string to your internal
string. Create two overloaded member functions called print( ): one
that takes no arguments and simply prints the message stored in
the object, and one that takes a string argument, which it prints in
addition to the internal message.

DP5 Every person is of a certain weight and age. Simulate a type person

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │Page 23 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

that initializes each person entity with his/her weight and age.
Accept and display this data using appropriate methods,
constructors and destructors. Every employee is also a person of a
certain age, weight and drawing a certain salary. Design an
appropriate solution that depicts the above scenario.

DP6 Imagine a tollbooth at a bridge. Cars passing by the booth are


expected to pay a 50 cent toll. Mostly they do, but sometimes a car
goes by without paying. The tollbooth keeps track of the number of
cars that have gone by, and of the total amount of money collected.
Model this tollbooth with a class called tollBooth. The two data
items are a type unsigned int to hold the total number of cars, and
a type double to hold the total amount of money collected. A
constructor initializes both of these to 0. A member function called
payingCar() increments the car total and adds 0.50 to the cash total.
Another function, called nopayCar(),increments the car total but
adds nothing to the cash total. Finally,a member function called
display() displays the two totals. Make appropriate member
functions const. Include a program to test this class. This program
should allow the user to push one key to count a paying car, and
another to count a nonpaying car. Pushing the Esc key should
cause the program to print out the total cars and total cash and
then exit.

DP7 Create a class called time that has separate int member data for
hours, minutes, and seconds. One constructor should initialize this
data to 0, and another should initialize it to fixed values. Another
member function should display it, in 11:59:59 format. The final
member function should add two objects of type time passed as
arguments. A main() program should create two initialized time
objects (should they be const?) and one that isn’t initialized. Then it
should add the two initialized values together, leaving the result in
the third time variable. Finally it should display the value of this

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │ Page 24 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

third variable. Make appropriate member functions const.

Advanced Problems

DA1 Define a base class Mammal with protected data members itsAge
and its Weight. Define constructor that set base values for its data
members, also define destructor for the class. Define constant
member functions to display animal weight and age and set
member functions to accept them from the user. Define an
enumerator to define different possible breeds of Dog. Define class
Dog that inherits Mammal. Define constructor and destructor for
Dog, Dog class should contain data member itsBreed of type
BREED. Also declare a constant member function getBreed() of
type BREED and define a function to set the animal breed.

DA2 Without using any library functions, design a C++ function


void append(char* str1, char* str2) { ... }
that takes as argument two strings str1, str2 and appends str2 to
str1. After calling append, the pointer str1 is supposed to point to
the concatenation of (the original) str1 and str2. The caller of
append has to make sure that enough memory for the result of
concatenation is available at the memory address that str1 points
to.

DA3 Create a class that includes a data member that holds a “serial
number” for each object created from the class. That is, the first
object created will be numbered 1, the second 2, and so on. To do
this,you’ll need another data member that records a count of how
many objects have been created so far. (This member should apply
to the class as a whole; not to individual objects. What keyword
specifies this?) Then, as each object is created, its constructor can
examine this count member variable to determine the appropriate
serial number for the new object. Add a member function that
permits an object to report its own serial number. Then write a
main() program that creates three objects and queries each one

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │Page 25 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

about its serial number. They should respond I am object number


2,and so on.

DA4 Create a class called ship that incorporates a ship’s number and
location. Number each ship object as it is created. Use two variables
of the angle class to represent the ship’s latitude and longitude. A
member function of the ship class should get a position from the
user and store it in the object; another should report the serial
number and position. Design a main() program that creates three
ships, asks the user to input the position of each, and then displays
each ship’s number and position.

Assignment Set: E

Objectives of the Assignment:


• Create and Implement re-uasble programming solutions
through appropriate usage of string handling, operator
overloading and inheritance.

CO/BTLCovered: CO1 & CO2/BTL2 & BTL3


Problems:

EP1 Define a class String that could work as a user-defined string type.
Include constructors that will enable us to create un-initialized
string. Also initialize a string object with a string constant at the
time of creation. Include a function that adds two strings to make a
third string. Write a complete program to test your class to see that
it does the following tasks: a)Creates un-initialized string objects

b)Creates objects with string constants

c)Concatenates two strings properly

d)Display a desired string object

EP2 Design a simple string manipulation solution in C++ that creates


two string objects and tests the same using the

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │ Page 26 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

==,!=,>,>=,<,<=operators.

EP3 Design a function to compare two given dates by the user. To store
a date, use a structure that contains three members namely date,
month and year. If the dates are equal, then display message as
“Equal” otherwise “Unequal”.

EP4 Write a function template to find the minimum of two numbers.


Instantiate the function using (int, int); (int, double); (double, int);
(double, double). Overload the same function to get them
minimum of two strings.

EP5 Design a class Animal that stores animal name. The class should be
self-sufficient to create a new animal with a name and display the
message“[AnimalType][AnimalName]says[AnimalSpeak].” Let
this class be used as the basis to create Cat, Dog and Cow animal
types.

EP6 Develop a solution to create a copier object using a powered


device, scanner and printer instance.

EP7 Write a program that substitutes an overloaded += operator for the


overloaded + operator in the STRPLUS program in this chapter.
This operator should allow statements like s1 += s2; where s2 is
added (concatenated) to s1 and the result is left in s1. The operator
should also permit the results of the operation to be used in other
calculations, as in s3 = s1 += s2;

Advanced Problems

EA1 Design a solution to check whether a sequence of strings entered by


the user contains at least two spaces or not.

EA2 Create a class Polar that represents the points on the plain as polar
coordinates (radius and angle). Create an overloaded +operator for
addition of two Polar quantities. “Adding” two points on the plain
can be accomplished by adding their X coordinates and then
adding their Y coordinates. This gives the X and Y coordinates of

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │Page 27 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

the “answer.” Thus you’ll need to convert two sets of polar


coordinates to rectangular coordinates, add them, then convert the
resulting rectangular representation back to polar.

EA3 A queue is a data storage device much like a stack. The difference
is that in a stack the last data item stored is the first one retrieved,
while in a queue the first data item stored is the first one retrieved.
That is, a stack uses a last-in-first-out (LIFO) approach, while a
queue uses first-in-first-out (FIFO). A queue is like a line of
customers in a bank: The first one to join the queue is the first one
served. Rewrite the STAKARAY program from this chapter to
incorporate a class called queue instead of a class called stack.
Besides a constructor, it should have two functions: one called put()
to put a data item on the queue, and one called get() to get data
from the queue. These are equivalent to push() and pop() in the
stack class.
Both a queue and a stack use an array to hold the data. However,
instead of a single int variable called top,as the stack has,you’ll
need two variables for a queue:one called head to point to the head
of the queue, and one called tail to point to the tail. Items are
placed on the queue at the tail (like the last customer getting in line
at the bank) and removed from the queue at the head. The tail will
follow the head along the array as items are added and removed
from the queue. This results in an added complexity: When either
the tail or the head gets to the end of the array, it must wrap
around to the beginning. Thus you’ll need a statement like if(tail
== MAX-1) tail = -1; to wrap the tail, and a similar one for the head.
The array used in the queue is sometimes called a circular buffer,
because the head and tail circle around it, with the data between
them.

EA4 A matrix is a two-dimensional array. Create a class matrix that


provides the safety feature; that is, it checks to be sure no array

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │ Page 28 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

index is out of bounds. Make the member data in the matrix class a
10-by-10 array. A constructor should allow the programmer to
specify the actual dimensions of the matrix (provided they’re less
than 10 by 10). The member functions that access data in the matrix
will now need two index numbers: one for each dimension of the
array. Here’s what a fragment of a main() program that operates on
such a class might look like: matrix m1(3, 4); // define a
matrix object int temp = 12345; // define an int value
m1.putel(7, 4, temp); // insert value of temp into matrix at 7,4
temp = m1.getel(7, 4); // obtain value from matrix at 7,4

EA5 Create a class called bMoney. It should store money amounts as


long doubles. Use the function mstold() to convert a money string
entered as input into a long double, and the function ldtoms() to
convert the long double to a money string for display. You can call
the input and output member functions getmoney() and
putmoney(). Write another member function that adds two
bMoney amounts; you can call it madd(). Adding bMoney objects
is easy: Just add the long double member data amounts in two
bMoney objects. Design a main() program that repeatedly asks the
user to enter two money strings, and then displays the sum as a
money string. Here’s how the class specifier might look:
class bMoney { private: long double money;
public: bMoney();
bMoney(char s[]);
void madd(bMoney m1, bMoney m2);
void getmoney();
void putmoney(); };.

Assignment Set: F

Objectives of the Assignment:


• Create and Implement efficient solutions to real world
problems using operator overloading.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │Page 29 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

CO/BTLCovered: CO1 to CO3/BTL2 to BTL6


Problems:

FP1 Design a basic solution to overload the assignment (=) operator to


work on two Distance objects.

FP2 Design a solution to overload the unary increment and binary


addition operator to work on two number objects

FP3 Define a class Point to represent the x, y and z coordinates of a 3D


Point. Overload the == and! = operators as friend functions to
compare two point objects.

FP4 Write a C++ program that reads a word from the keyboard, stores
it in a string, and checks whether the word is a palindrome. A
palindrome reads the same from left to right as from right to left.
The following are examples of palindromes: "OTTO, " "deed, " and
"level." Use the subscript operator []. Modify the program to
continually read and check words

FP5 Write a C++ program to

• initialize a string s1 with the string "As time by ..."


and a second string s2 with the string "goes",

• insert string s2 in front of "by" in string s1,

• erase the remainder of string s1 after the substring


"by",

• Replace the substring "time" in s1 with "Bill".

In each case, your program should determine the position of the


substring. Output string s1 on screen at the beginning of the
program and after every modification.

FP6 Define a class to represent Complex Numbers. Overload the


arithmetic operators (+, -, * and \) to work on two complex objects.

Advanced Problems

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │ Page 30 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

FA1 class Cents {private: int mCents;


public: Cents(int nCents=0) { mCents = nCents; }
int GetCents() { return mCents; }
void SetCents(int nCents) { mCents = nCents; }};
Overload the class above to allow us to cast our Cents class into an
int.

FA2 Matrices are a key component of linear algebra, and are often used
to do geometric modeling and 3d computer graphics work. In this
case, all you need to recognize is that the Matrix class is a 4 by 4
two-dimensional array of doubles. Because the () operator can take
as many parameters as we want it to have, we can declare a version
of operator () that takes two integers and use it to access our two-
dimensional array. Use the class defined below to overload the ()
operator class Matrix {private: double adData[4][4];
public: Matrix(){ // Set all elements of the matrix to 0.0
for (int nCol=0; nCol<4; nCol++)
for (int nRow=0; nRow<4; nRow++)
adData[nRow][nCol] = 0.0; }};

FA3 Also overload the unary operators +, - and! to work on Point class.

FA4 Given the class definition below, complete the class definitions
with the following operator functions

class MyComplex {private: double real, imag;

public: MyComplex(){real = 0; imag = 0;}

MyComplex(double r, double i) {real = r; imag = i;}

double getReal() const {return real;}

double getImag() const { return imag; }

i. Overload the = operator to assign one MyComplex object


to another.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │Page 31 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

ii. Overload the + operator to add two MyComplex objects

iii. Overload the << and >> operators to display and input
MyComplex objects

iv. Overload the – operator as post-fix as well as prefix.

FA5 #ifndef _EURO_H_


#define _EURO_H_
#include<sstream>
#include<iomanip>
using namespace std;
class Euro{ long data;//Euros*100+cents
public:
Euro(int euro=0,int cents=){}
Euro(double x){}
long getWholePart()const{return data/100;}
int getCents()const(return (int)(data5100);}
double asDouble()const{return(double)data/100.0;}
String asString()const{stringstream ss;
Long temp=data; If(temp<0){ss<<’-‘; Temp=-temp;}
ss<<temp/100<<’-‘<<setfill(‘0’)<<setw(2)<<temp%100;
return ss.str();}
#endif
The above Euro class represents the new European currency. Class
member data stores a given amount of Euro as an integer in the
format (integer part)*100+cents. Complete the above class
definition with the following friend operator functions:
i. Overload negation operator
ii. Overload binary += operator
iii. Overload binary -= operator

FA6 Overload the binary [] operator function to represent an array with

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │ Page 32 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

range checking on the FloatArr class given below: #define MAX


100 class FloatArr{ float v[MAX]; public: float& operator[](int i);
static int MaxIndex(){return MAX-1;}}; };

Assignment Set: G

Objectives of the Assignment:


• Implement real-world, optimized computing solutions
through appropriate usage of the inheritance and overloading.

CO/BTLCovered: CO1 to CO3/BTL2 to BTL6


Problems:

GP1 Create an inheritance hierarchy that a bank might use to represent


customers' bank accounts. All customers at this bank can deposit
(i.e., credit) money into their accounts and withdraw (i.e., debit)
money from their accounts. More specific types of accounts also
exist. Savings accounts, for instance, earn interest on the money
they hold. Current accounts, on the other hand, charge a fee per
transaction (i.e., credit or debit). Simple account object creation
should be disallowed.

GP2 Define a class fraction that accepts a number and its denominator
from the user. Overload the conversion operator such that a
fraction object can be assigned to a float variable and the result of
division can be returned as a float..

GP3 Complete the following class declaration:


class A { public: A(){}
explicit A(int n):data(n) {}
int data;
A& operator+(A&);
A operator++(int); A& operator++(); };

GP4 Design a solution to accept a float value from the user and round it
off to the nearest integer using Macros.

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │Page 33 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

GP5 Imagine a publishing company that markets both book and


audiocassette versions of its works. Create a class publication that
stores the title (a string) and price (type float) of a publication.
From this class derive two classes: book, which adds a page count
(type int), and tape, which adds a playing time in minutes (type
float). Each of these three classes should have a getdata() function
to get its data from the user at the keyboard, and a putdata()
function to display its data. Write a main() program to test the book
and tape classes by creating instances of them, asking the user to
fill in data with getdata(), and then displaying the data with
putdata()..

GP6 Start with the publication, book, and tape classes of GP6. Add a
base class sales that holds an array of three floats so that it can
record the dollar sales of a particular publication for the last three
months. Include a getdata() function to get three sales amounts
from the user, and a putdata() function to display the sales figures.
Alter the book and tape classes so they are derived from both
publication and sales. An object of class book or tape should input
and output sales data along with its other data. Write a main()
function to create a book object and a tape object and exercise their
input/output capabilities.

Advanced Problems

GA1 class Distance { private: int meter;


public: Distance(): meter(0) { } //friend function
friend int addFive(Distance); };
Complete the above class definition and demonstrate its use?

GA2 class Fraction{ int gcd(int a, int b)


{return b==0?a:gcd(b,a%b);}
public: Fraction(int n,int d=1):n(n/gcd(n,d)),(d/gcd(n,d)){}
Int num() const(return n;}
Int den() const{return d;}

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │ Page 34 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

Fraction& operator *= (const Fraction& rhs){}


Ostream& operator <<(ostream& out,const Fraction f){}
Bool operator ==(const Fraction& lhs, const Fraction &rhs){}
Bool operator !=( const Fraction& lhs, const Fraction &rhs){}
Fraction operator *(Fraction lhs, const Fraction& rhs){}};
Complete the above class definition and demonstrate use of
overloaded operators on Fraction objects.

Assignment Set: H

Objectives of the Assignment:

Implement real-world computing solutions through appropriate


usage of the Conatinership and File Handling.

CO/BTLCovered: CO1 to CO3/BTL2 to BTL6

Problems:

HP1 Write a program to demonstrate composition through a Point class


to map a creature’s location.

HP2 Write a program to demonstrate aggregation through a Teacher-


Department class.

HP3 Design a solution to write data to a disk file and then read them
back and finally display them on the screen.

HP4 Design a solution to find the size of a file.

HP5 Design a basic solution to copy the contents of one file to another.

HP6 Design a solution to find vowels in a text file and replace them with
a ‘#’ symbol.

Advanced Problems:

HA1 Design a C++ solution to read data from a text file and output it in
a blank file. Format the data in CSV (Comma Seperated Values)
format with 25 columns per row max.

HA2 Design a program that emulates the DOS COPY command. That is,

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │Page 35 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

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>ocopy srcfile.cpp destfile.cpp.

HA3 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.

HA4 Create a linked list class. Design a program that gives the user four
options, which can be selected by pressing a key.
• Add a link to the list in memory (the user supplies the data,
which is one integer)
•Display the data from all the links in memory
•Write the data for all the links to a disk file (creating or truncating
the file as necessary)
• Read all the data back from the file, and construct a new linked
list in which to store it

Assignment Set: I

Objectives of the Assignment:

Apply all C programming constructs and datatypes to solve real


world problems with effective use of Exception Handling.

CO/BTLCovered: CO1 to CO4/BTL2 to BTL6

Problems:

IP1 Design a class called myexception which is a subclass of


std::exception class. Override the what() function to tell the user

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │ Page 36 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

“My Exception Occurred” in case an exception of type


myexception is thrown

IP2 Design a function that divides two numbers entered by the user
and returns the resultant value with double precision. The function
should check if the denominator is 0, then it should throw a Divide
by Zero exception in your code

IP3 Design a solution to manually throw an integer exception in your


code.

IP4 Design a base class with a virtual destructor. Design a class


Derived that inherits the Base class. Define a function f() that
throws an exception of type derived. Write code to demonstrate
rethrowing this exception.

IP5 Design a function int intDivEx(int numerator, int denominator).


The function should throw an overflow_error if there is an attempt
of division by zero, else it should return the result. Test the
function to generate an overflow_error as well as show the result of
division.

Advanced Problems:

IA1 Design a solution to compute square root of a number. The input


value must be tested for value. If negative the user defined function
neg_sqrt() should raise an exception.

IA2 When an exception is thrown, all objects created inside the


enclosing try block are destructed before the control is transferred
to catch block. Demonstrate the above statement with an example

IA3 Add an exception class to the Distance class. Throw an exception in


all the places where an error message is displayed. Use an
argument to the exception constructor to report where the error
occurred and the specific cause of the error (inches not a number,
inches out of range, and so on). Also, throw an exception when an
error is found within the isint() function (nothing entered, too

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │Page 37 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

many digits, nondigit character, integer out of range). You might


also want to throw an exception in the two-argument
constructor,in case the programmer initializes a Distance value
with its inches member out of range.

Assignment Set: J

Objectives of the Assignment:

Create reusable, robust, optimized real world, algorithmic


solutions through Generic Programming and STL.

CO/BTLCovered: CO1 to CO4/BTL2 to BTL6

Problems:

JP1 Demonstrate creation of template function called swapargs. Use


it to swap two variables of integer, character and floating point
type.

JP2 Demonstrate the creation and usage of template classes with two
parameters. Define a class myclass with two parameterised data
members. Define a constructor to initialise these members and a
method show() to display their values. Instantiate the above class
template with <int, double> and <char, char*> template classes
at runtime

JP3 Design a solution to implement Linear and binary search using


generic functions

JP4 Design a basic solution to design a single linked list using


templates. Implement a class template to represent a single
linked list. The class template should contain functions to
insert/delete a node at the provided position and a function to
display all elements of the list. Use the class template
specification below to implement the above:
Template <class T>
Class LinkedList { struct listnode{ T value;
listnode* next;

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │ Page 38 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

listnode(T v,listnode* n=NULL){value=v; next=n;}};


listnode* head;
public: LinkedList(){head=NULL;}
~LinkedList(){}
Void displaylist(); Void add(T v); Void Remove(T v); };

JP5 Implement Vectors using STL.

JP6 Construct a deque using STL.

JP7 Implement Stack through STL

Advanced Problems:

JA1 Design a solution to accept an integer array and implement


find(), count(), sort() and search() algorithms on the same

JA2 Design a solution to implement an Associative Array using Map


container

JA3 Implement BFS and DFS using STL

JA4 Implement Dijkstras algorithm using STL

Minor Project in C++

Objectives of the Assignment: Solve/Simulate a real-world problem through an


efficient solution using all features of the C programming language.

CO/BTLCovered: CO1 to CO5/BTL2 to BTL6

S. No. Suggested Topics for Project

1. Hangman Game

2. MCD Multi-level Parking & Billing Utility

3. AC Feasibility Calculator

4. Alarm Clock Utility

5. Login-Logout Tracker

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │Page 39 of 41
Laboratory Manual for MCA-153; Programming in C Lab. | Version 10.0

S. No. Suggested Topics for Project

6. See your C Tester

7. Power Vocab

8. Sales Data Forecaster

9. Automatic Traffic Challan Generator Utility

10. Network Mapper

11. Snake Mania Game

12. Metro Route Tracer Utility

13. File Encryption-Decryption Utility

14. Horoscope Utility

15. Sudoku Game

16. Client Server Chat Utility

17. Password Manager

18. Food Ordering Utility

19. Typing Game

20. KBC Quiz Game Utility

*******

© Bharati Vidyapeeth’s Institute of Computer Applications and Management (BVICAM), New Delhi │ Page 40 of 41
APPENDIX-A

Template for the Index of Lab File

WEEK PROBLEMS WITH DESCRPTION PAGE SIGNATURE


NO. NO. OF THE
TEACHER
WITH DATE

1 AP1

AP2

AP3

2 AA1

AA2

AA3

3 BP1

BP2

BP3

BP4

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

You might also like