19
GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER ENGINEERING (07), INFORMATION TECHNOLOGY (16) & INFORMATION & COMMUNICATION TECHNOLOGY (32) OBJECT ORIENTED PROGRAMMING WITH C++ SUBJECT CODE: 2140705 B.E. 4 th SEMESTER Type of course: Core Course Prerequisite: Programming Fundamentals Rationale: The object oriented approach for software development has become the de-facto standard for the industry to develop the product based or customized software based on customer demand. The software libraries developed for various fields also follows the phenomena of object oriented development. The subject covers the basic concepts of the object oriented paradigm and popular object oriented programming language C++. The subject covers the basics of C++, objects and classes, Inheritance, Polymorphism, I/O and file management, and advance topics including templates, exceptions and STL (Standard Template Library). Teaching and Examination Scheme: Teaching Scheme Credits Examination Marks Total Marks L T P C Theory Marks Practical Marks ESE (E) PA (M) ESE (V) PA (I) PA ALA ESE OEP 4 0 4 8 70 20 10 20 10 20 150 Content: Sr. No. Topics Teaching Hrs. Module Weightage 1 Concepts of OOP : Introduction OOP, Procedural Vs. Object Oriented Programming, Principles of OOP, Benefits and applications of OOP 4 8% 2 C++ Basics : Overview, Program structure, namespace, identifiers, variables, constants, enum, operators, typecasting, control structures 6 10% 3 C++ Functions : Simple functions, Call and Return by reference, Inline functions, Macro Vs. Inline functions, Overloading of functions, default arguments, friend functions, virtual functions 6 12% 4 Objects and Classes : Basics of object and class in C++, Private and public members, static data and function members, constructors and their types, destructors, operator overloading, type conversion 8 15% 5 Inheritance : Concept of Inheritance, types of inheritance: single, multiple, multilevel, hierarchical, hybrid, protected members, overriding, virtual base class 8 15% 6 Polymorphism : Pointers in C++, Pointes and Objects, this pointer, virtual and pure virtual functions, Implementing polymorphism 6 10% 7 I/O and File Management : Concept of streams, cin and cout objects, C++ stream classes, Unformatted and formatted I/O, manipulators, File stream, C++ File stream classes, File management functions, File modes, Binary and random Files 8 15% 8 Templates, Exceptions and STL : What is template? function templates and class templates, Introduction to exception, try-catch- throw, multiple catch, catch all, rethrowing exception, implementing 8 15%

GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER … · - Write the simple C++ programs using the variables, operators, control structures, functions and I/O objects cin and cout - Write

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER … · - Write the simple C++ programs using the variables, operators, control structures, functions and I/O objects cin and cout - Write

GUJARAT TECHNOLOGICAL UNIVERSITY

COMPUTER ENGINEERING (07), INFORMATION TECHNOLOGY (16) &

INFORMATION & COMMUNICATION TECHNOLOGY (32) OBJECT ORIENTED PROGRAMMING WITH C++

SUBJECT CODE: 2140705

B.E. 4th SEMESTER

Type of course: Core Course

Prerequisite: Programming Fundamentals

Rationale: The object oriented approach for software development has become the de-facto standard for the

industry to develop the product based or customized software based on customer demand. The software

libraries developed for various fields also follows the phenomena of object oriented development. The

subject covers the basic concepts of the object oriented paradigm and popular object oriented programming

language C++. The subject covers the basics of C++, objects and classes, Inheritance, Polymorphism, I/O

and file management, and advance topics including templates, exceptions and STL (Standard Template

Library).

Teaching and Examination Scheme:

Teaching Scheme Credits Examination Marks Total

Marks L T P C Theory Marks Practical Marks

ESE

(E)

PA (M) ESE (V) PA

(I) PA ALA ESE OEP

4 0 4 8 70 20 10 20 10 20 150

Content:

Sr.

No. Topics

Teaching

Hrs.

Module

Weightage

1 Concepts of OOP : Introduction OOP, Procedural Vs. Object Oriented

Programming, Principles of OOP, Benefits and applications of OOP

4 8%

2 C++ Basics : Overview, Program structure, namespace, identifiers,

variables, constants, enum, operators, typecasting, control structures

6 10%

3

C++ Functions : Simple functions, Call and Return by reference,

Inline functions, Macro Vs. Inline functions, Overloading of functions,

default arguments, friend functions, virtual functions

6 12%

4

Objects and Classes : Basics of object and class in C++, Private and

public members, static data and function members, constructors and

their types, destructors, operator overloading, type conversion

8 15%

5

Inheritance : Concept of Inheritance, types of inheritance: single,

multiple, multilevel, hierarchical, hybrid, protected members,

overriding, virtual base class

8 15%

6 Polymorphism : Pointers in C++, Pointes and Objects, this pointer,

virtual and pure virtual functions, Implementing polymorphism

6 10%

7

I/O and File Management : Concept of streams, cin and cout objects,

C++ stream classes, Unformatted and formatted I/O, manipulators, File

stream, C++ File stream classes, File management functions, File

modes, Binary and random Files

8 15%

8

Templates, Exceptions and STL : What is template? function

templates and class templates, Introduction to exception, try-catch-

throw, multiple catch, catch all, rethrowing exception, implementing

8 15%

Page 2: GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER … · - Write the simple C++ programs using the variables, operators, control structures, functions and I/O objects cin and cout - Write

user defined exceptions, Overview and use of Standard Template

Library

Suggested Specification table with Marks (Theory):

Distribution of Theory Marks

R Level U Level A Level N Level E Level

14 24 24 4 4

Legends: R: Remembrance; U: Understanding; A: Application, N: Analyze and E: Evaluate and above Levels

(Revised Bloom’s Taxonomy)

Note: This specification table shall be treated as a general guideline for students and teachers. The actual

distribution of marks in the question paper may vary slightly from above table.

Reference Books:

1. Object Oriented Programming With C++, E Balagurusamy, TMH

2. C++ Programming, Black Book, Steven Holzner, dreamtech

3. Object Oriented Programming in Turbo C++, Robert Lafore, Galgotia

4. Object Oriented Programming with ANSI and Turbo C++, Ashok Kamthane, Pearson

5. The Compete Reference C++, Herbert Schlitz, TMH

6. C++ and Object Oriented Programming Paradigm, PHI

7. C++ : How to Program, 9th Edition, Deitel and Deitel, PHI

8. Object Oriented Programming with C++, Saurav Sahay, Oxford

Course Outcome:

After learning the course the students should be able to:

- Describe the important concepts of object oriented programming like object and class,

Encapsulation, inheritance and polymorphism

- Write the skeleton of C++ program.

- Write the simple C++ programs using the variables, operators, control structures, functions and I/O

objects cin and cout

- Write the simple object oriented programs in C++ using objects and classes.

- Use features of C++ like type conversion, inheritance, polymorphism, I/O streams and files to

develop programs for real life problems.

- Use advance features like temples and exception to make programs supporting reusability and

sophistication.

- Use standard template library for faster development.

- Develop the applications using object oriented programming with C++.

List of Experiments:

Practical list should be based on the topics covered. Following guideline is to be kept in mind while framing

the list:

- At least 25 programs are to be assigned

- Programs should cover particular feature from syntactic concepts together with OOP feature and

definition based on real life problem.

- Practical list should cover entire syllabus.

Design based Problems (DP)/Open Ended Problem:

Page 3: GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER … · - Write the simple C++ programs using the variables, operators, control structures, functions and I/O objects cin and cout - Write

1. Develop an object oriented application to perform all the basic operations like insert, delete, search

on binary tree.

2. Develop an object oriented application to compute the Income-tax for the salaried person.

3. Develop an object oriented system “Visiting Card Management” which allows user to add, delete

and update and search the visiting card details.

4. Develop an object oriented system “Student Attendance Management” for recording and analyzing

the student attendance.

5. Develop a library for performing various Matrix operations. Use templates to make them generalized

for any data type.

Major Equipment:

- Latest Desktop PCs with any C++ compiler

List of Open Source Software/learning website:

- Open source software dev C++

- www.nptel.ac.in

- www.learncpp.com

ACTIVE LEARNING ASSIGNMENTS: Preparation of power-point slides, which include videos,

animations, pictures, graphics for better understanding theory and practical work – The faculty will allocate

chapters/ parts of chapters to groups of students so that the entire syllabus to be covered. The power-point

slides should be put up on the web-site of the College/ Institute, along with the names of the students of the

group, the name of the faculty, Department and College on the first slide. The best three works should submit

to GTU.

Page 4: GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER … · - Write the simple C++ programs using the variables, operators, control structures, functions and I/O objects cin and cout - Write

Laxmi Institute of Technology, Sarigam Approved by AICTE, New Delhi; Affiliated to Gujarat Technological University, Ahmedabad

Department of Computer Science and Engineering

LECTURE PLAN Department: Computer Science & Engineering Name of Subject In charge: Mr.Bhavesh K.Patel

Subject Name: Object Oriented Programming with C++ Subject Code: 2140705 Academic Year: 2018-19 Semester: 4

Lecture No. Topics To Be Covered Planned

Date Actual Date

Remark/ Teaching

Aids/ Books

Unit-01: Concepts of OOP 01 Introduction OOP

02 Procedural Vs. Object Oriented Programming

03 Principles of OOP

04 Benefits and applications of OOP

Unit-02: C++ Basics 05 Overview, Program structure

06 namespace, identifiers

07 namespace, identifiers

08 variables, constants, enum

09 variables, constants, enum

10 Operators

11 Operators

12 Typecasting

13 control structures

Unit-03: C++ Functions 14 Simple functions

15 Call and Return by reference

16 Call and Return by reference

17 Inline functions Macro Vs. Inline functions

18 Overloading of functions

Page 5: GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER … · - Write the simple C++ programs using the variables, operators, control structures, functions and I/O objects cin and cout - Write

Laxmi Institute of Technology, Sarigam Approved by AICTE, New Delhi; Affiliated to Gujarat Technological University, Ahmedabad

Department of Computer Science and Engineering

19 Overloading of functions

20 default arguments, friend functions

21 virtual functions

Unit-04: Objects and Classes 22 Basics of object and class in C++,

23 Private and public members

24 Private and public members

25 data and function members

26 data and function members

27 constructors and their types,

28 destructors,

29 operator overloading (Unary)

30 operator overloading (Binary)

31 type conversion

Unit-05: Inheritance

32 Concept of Inheritance

33 types of inheritance : single

34 types of inheritance : single

35 Multiple inheritance

36 multilevel inheritance

37 hierarchical inheritance

38 hybrid inheritance

39 protected members

40 overriding, virtual base class

Unit-06: Polymorphism 41 Pointers in C++

Page 6: GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER … · - Write the simple C++ programs using the variables, operators, control structures, functions and I/O objects cin and cout - Write

Laxmi Institute of Technology, Sarigam Approved by AICTE, New Delhi; Affiliated to Gujarat Technological University, Ahmedabad

Department of Computer Science and Engineering

Total Planned Lectures: 63 Total Actual Lectures: Subject In charge

Head of Department

42 Pointes and Objects

43 Pointes and Objects

44 this pointer

45 virtual funtion

46 pure virtual functions

47 Implementing polymorphism

Unit-07: I/O and File Management 48 Concept of streams cin and cout objects

49 C++ stream classes, Unformatted I/O

50 formatted I/O

51 Manipulators

52 File stream, C++ File stream classes

53 File management functions

54 File modes

55 Binary and random Files

Unit-08: Templates, Exceptions and STL

56 What is template?

57 function templates and class templates

58 Introduction to exception

59 try-catch- throw,

60 multiple catch, catch all

61 rethrowing exception,

62 implementing user defined exceptions

63 Overview and use of Standard Template Library

Page 7: GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER … · - Write the simple C++ programs using the variables, operators, control structures, functions and I/O objects cin and cout - Write

Laxmi Institute of Technology, Sarigam Approved by AICTE, New Delhi; Affiliated to Gujarat Technological University, Ahmedabad

Department of Computer Science and Engineering

Page 8: GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER … · - Write the simple C++ programs using the variables, operators, control structures, functions and I/O objects cin and cout - Write

Laxmi Institute of Technology, Sarigam Approved by AICTE, New Delhi; Affiliated to Gujarat Technological University, Ahmedabad

LABORATORY PLAN

Department: Computer Science & Engineering Name of Subject In charge: Ms. Rama M. Maliya / Ms. Shanthini Akbar

Subject Name:

OBJECT ORIENTED PROGRAMMING WITH C++

Subject Code: 2140705

Academic Year: 2016-17 Semester: IV Batch: G

Lab No. Name of Experiments

01

Basics of C++: 1. Write a C++ program to display Your Name, Address and City in different lines. 2. Write a C++ program to find the area and volume of sphere. Formulas are: Area = 4*PI*R*R Volume =

4/3*PI*R*R*R.

3. Write a temperature – conversion program that gives the user the option of converting Fahrenheit to Celsius or Celsius to Fahrenheit. Then carry out the conversion. Use Floating point numbers.

Formula: C= (F- 32)/1.8

02

Arrays and Control Structures: 1. Write a C++ program to find Fibonacci Series of given input by the end user. 2. Write a C++ program to find all the prime number between two given numbers. 3. Write a C++ program to print the accepted no and its reverse no. 4. Write a C++ program to convert decimal to binary and decimal to octal. 5. Write a C++ program to sort given numbers in ascending order. 6. Write a C++ program which calculates total marks and percentage of 5 subjects for 5 students using array

and structure.

03

Functions: 1. Write a C++ program to find factorial of given number using recursion.

2. Write a C++ program which shows the use of inline functions.

3. Write a C++ program to find a mean value of given number using friend function. 4. Write a function to calculate the area of the rectangle whose length and width are provided as arguments.

If width is not provided then it has to be considered as a square. Use a single function sq_area() with default arguments. (Use function overloading)

04

Objects and Classes: 1. Construct a class called Calendar with data members as date, month and year. Implement constructors,

overloaded constructors and destructors for the same. Implement a function called nextday(), which will increment the date by one. Write a function display() to print date, month and year. Consider all situations.

Page 9: GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER … · - Write the simple C++ programs using the variables, operators, control structures, functions and I/O objects cin and cout - Write

Laxmi Institute of Technology, Sarigam Approved by AICTE, New Delhi; Affiliated to Gujarat Technological University, Ahmedabad

e.g. Initially 31/07/2002 Tomorrow it is: 01/08/2002

2. Create two classes DM and DB which store the value of distances. DM stores distances in meter and centimeters and DB in feet and inches. Write a program that read values of the class objects and add one object of DM with another object of DB.

3. Construct a class called Stack with data members as top, character (Ch.). Implements Parameterize Constructor for the same. Take a member Function Push() and Pop() to implement Stack.

05

Assigning object & Passing object as a function argument: 1. Write a program to find factor of given number using assigning objects fundamental. 2. Write a program to addition of two heights given in feet and inches with pass object as a function

argument.

06

Copy Constructor: 1. Write a program to find factorial of given number using copy constructor.

07

Constructor Overloading & Operator Overloading: 1. Write a C++ program to overload all arithmetic operators. 2. Write a C++ program which calculates area of circle, rectangle, triangle using constructor overloading and

destructor.

08

Inheritance: 1. Create a Class student stores the roll no, Class test stores the marks obtained in two subjects and class

result contains the total marks obtain in the test. Class result can inherit the details of the marks obtain in the test and the roll no. of the student class.

2. Write a C++ program which contains three classes Circle, Triangle, and Rectangle, where Circle is the base class for Triangle and Rectangle. Each of these three classes implements a function area() which finds area of object of that class. Now use concept of virtual function in this program i.e. call appropriate area() function using base class (Circle in this case) pointer only.

3. Write a C++ program which demonstrates hybrid inheritance.

09

Polymorphism: 1. Write a C++ program to demonstrate runtime polymorphism.

10 File Management:

1. Write a C++ program that copy contents of one file to another file.

11

Templates: 1. Design a generic function to sort the data using bubble sort. Use the function to sort the array of integer as

well as floating point data type. 2. Design a template class to simulate the STACK. It should have at least PUSH, POP operations and error

checks, if any.

Page 10: GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER … · - Write the simple C++ programs using the variables, operators, control structures, functions and I/O objects cin and cout - Write

Laxmi Institute of Technology, Sarigam Approved by AICTE, New Delhi; Affiliated to Gujarat Technological University, Ahmedabad

12

Exception Handling: 1. Design a class having two data members. Define a member function to find out the division of these

numbers. The function should throw an exception when the denominator is zero. 2. Design a class to simulate the STACK, which raises an exception whenever overflow and underflow

condition occurs. Include the basic PUSH and POP operations.

Subject In charge

Head of Department

Page 11: GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER … · - Write the simple C++ programs using the variables, operators, control structures, functions and I/O objects cin and cout - Write

Laxmi Institute of Technology, Sarigam Approved by AICTE, New Delhi; Affiliated to Gujarat Technological University, Ahmedabad

Department of Computer Science and Engineering

Department: Computer Science &Engineering Name of Subject In charge: Mr.Bhavesh K.Patel

Subject Name:

OBJECT ORIENTED PROGRAMMING WITH C++

Subject Code: 2140705

Academic Year: 2018-19 Semester: IV List Of Assignments

Assignment 1 Submission Date : 06/02/2019 Q-1-

Give the Difference Between: i) OOP Vs POP ii) Structure Vs Class

Q-2- Explain Following Terms With Program i) Default Argument ii) Static data member iii) Static member function

Q-3 What is inline function?Explain it with program. Assignment 2 Submission Date : 25/02/2019

1. Explain the manipulator endl and setw with example. 2. Describe the difference in the implementation of enum data type in ANSI C and C++. 3. What is reference variable? What is its major use? 4. Explain Memory Management Operator with example.

Assignment 3 Submission Date : 18/03/2019 1. Define a class complex, having data member as X and Y, Define a friend function sum()

to add two complex numbers and display all numbers using show() friend function. 2. Explain the following terms with suitable example. (i) Pure virtual functions (ii)friend

function 3. What is virtual function? What is the use of virtual function? 4. What is a constructor? Explain types of constructor with example.

Assignment 4 Submission Date : 08/04/2019 1. What is polymorphism? Explain types of polymorphism. 2. Show the use of multiple inheritances with the help of proper programming example. 3. Write a C++ program that illustrates the concept of accessing strings using pointers and

arrays. 4. How to create array of objects using pointers? 5. What is pure virtual function? Why we use virtual function.

Page 12: GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER … · - Write the simple C++ programs using the variables, operators, control structures, functions and I/O objects cin and cout - Write

Laxmi Institute of Technology , Sarigam Approved by AICTE, New Delhi; Affiliated to Gujarat Technological University, Ahmedabad

Academic Year 2018-19 Centre Code: 086 Examination : MID-I Branch: CSE Semester: IV Sub Code: 2140705 Sub: OOPC Date:30/01/2019 Time: 9:00 to 10:00 AM Marks: 20 Note: Attempt all questions. Figures to the right indicate full marks. Q.1 (a) Give Difference between.(Any One)

i) Structure Vs. Class in C++ ii) OOP Vs. POP 2

(b) What is inline function explain it with example and also explain merits and demerits of inline function.

3

Q.2 (a) Describe following terms in C++ with example (Program).(Any Two) i) Default Argument ii) static data member iii) static member function

4

(b) Write a C++ program which calculates area of cube, cylinder and rectangle box using concept of function overloading.

4

Q.3 (a) Explain scope resolution operator with program. 2

(b) Create a class called item having private data members (item_code, item_name, cost and discount). Also class includes private member function as purchase () which include values of all above data members. Define main () function having two objects called T1 and T2. Define public member functions for. i) getdata() to initialize values to data members.(define it outside the class) ii) putdata() to display values of data members.(define it inside the class) -Also show how to access private member function purchase () using public member function.

5

Laxmi Institute of Technology , Sarigam Approved by AICTE, New Delhi; Affiliated to Gujarat Technological University, Ahmedabad

Academic Year 2018-19 Centre Code: 086 Examination : MID-I Branch: CSE Semester: IV Sub Code: 2140705 Sub: OOPC Date:30/01/2019 Time: 9:00 to 10:00 AM Marks: 20 Note: Attempt all questions. Figures to the right indicate full marks. Q.1 (a) Give Difference between.(Any One)

i) Structure Vs. Class in C++ ii) OOP Vs. POP 2

(b) What is inline function explain it with example and also explain merits and demerits of inline function.

3

Q.2 (a) Describe following terms in C++ with example (Program).(Any Two) i) Default Argument ii) static data member iii) static member function

4

(b) Write a C++ program which calculates area of cube, cylinder and rectangle box using concept of function overloading.

4

Q.3 (a) Explain scope resolution operator with program. 2

(b) Create a class called item having private data members (item_code, item_name, cost and discount). Also class includes private member function as purchase () which include values of all above data members. Define main () function having two objects called T1 and T2. Define public member functions for. i) getdata() to initialize values to data members.(define it outside the class) ii) putdata() to display values of data members.(define it inside the class) -Also show how to access private member function purchase () using public member function.

5

Page 13: GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER … · - Write the simple C++ programs using the variables, operators, control structures, functions and I/O objects cin and cout - Write
Page 14: GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER … · - Write the simple C++ programs using the variables, operators, control structures, functions and I/O objects cin and cout - Write

1

Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTER–IV (NEW) EXAMINATION – WINTER 2017

Subject Code: 2140705 Date: 29/11/2017 Subject Name: Object Oriented Programming With C++ Time: 02:30 PM TO 05:00 PM Total Marks: 70 Instructions:

1. Attempt all questions. 2. Make suitable assumptions wherever necessary. 3. Figures to the right indicate full marks.

Q.1 (a) What is object oriented programing? What are the advantages of an

object-oriented programing paradigm? 03

(b) How is polymorphism achieved at (1) compile time, and (2) run time? 04

(c) What is overloading of a function? When do we use this concept?

Explain with an example. 07

Q.2 (a) What is STL? How is it different from the C++ Standard library? 03

(b) What is a file mode? Describe the various file mode options available. 04

(c) What is a reference variable? What is its major use? Explain with an

example. 07

OR

(c) What do you mean by dynamic binding? How is it useful in OOP?

Explain with an example. 07

Q.3 (a) An unsigned int can be twice as large as the signed int. Explain how? 03

(b) Can we have more than one constructor in a class? If yes, explain the

need for such a situation. 04

(c) What is a conversion function? How is it created. Explain with example. 07

OR

Q.3 (a) When do we declare a member of a class static? Why? 03

(b) Distinguish between following two statements:

Time T2(T1);

Time T2= T1;

T1 and T2 are objects of Time class.

04

(c) What is an operator function? Explain with an example. 07

Q.4 (a) Why do we need virtual functions? 03

(b) When do we use protected visibility specifier to a class member? Explain

with an example. 04

(c) Explain with an example, how would you create a space for an array of

objects using pointers. 07

OR

Q.4 (a) What is a virtual base class? 03

(b) When do we make a virtual function “pure”? What are the implications

of making a function a pure virtual function? 04

(c) What are the different forms of inheritance? Give an example for each. 07

Q.5 (a) How do the following two statements differ in operation?

cin>>c;

cin.get(c);

03

(b) Describe the various approaches by which we can detect the end of file

condition. 04

(c) Write a function template for finding the minimum value from an array. 07

Page 15: GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER … · - Write the simple C++ programs using the variables, operators, control structures, functions and I/O objects cin and cout - Write

2

OR

Q.5 (a) Discuss the syntax of set () function. 03

(b) Write a program that reads a text file and creates another file that is

identical except that every sequence of consecutive blank space is replace

by a single space.

04

(c) Write a class template to represent a generic vector. Include member

function to create the vector and to modify the value of a given element. 07

*************

Page 16: GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER … · - Write the simple C++ programs using the variables, operators, control structures, functions and I/O objects cin and cout - Write

1

Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTER–IV (NEW) EXAMINATION – WINTER 2018

Subject Code:2140705 Date:12/12/2018 Subject Name:Object Oriented Programming With C++ Time: 02:30 PM TO 05:00 PM Total Marks: 70 Instructions:

1. Attempt all questions. 2. Make suitable assumptions wherever necessary. 3. Figures to the right indicate full marks.

MARKS

Q.1 (a) Differentiate Object Oriented Programming (OOP) and Procedure

Oriented Programming (POP). 03

(b) Write a C++ program to find out the sum and average of three numbers

using nesting of member function.

04

(c) Describe the basic structure of a C++ program with all necessary

blocks. 07

Q.2 (a) When can you make function inline? What are the advantages of

making function inline? 03

(b) Following is a main() program.

void main()

{

time T1;

int duration = 85;

T1 = duration;

}

Where time is a class which contains variables hrs and minutes.

duration stores total time in minutes. Define a class time with

necessary functions to break up the duration in maximum hours and

remaining minutes and store them into hrs and minutes respectively.

04

(c) Write a C++ program that overloads + operator to add two complex

numbers. 07

OR

(c) Write a C++ program to find volume of cube, cylinder and rectangular

box using concepts of function overloading.

(volume of cube = s3, volume of cylinder is π*r2*h, volume of

rectangular box is l*b*h)

07

Q.3 (a) An unsigned int can be twice as large as the signed int. Explain how? 03

(b) Write a C++ program to swap the values of pair of integers using

function and call by reference. 04

(c) Explain various forms of inheritance with suitable diagrams and

example of each. 07

OR

Q.3 (a) Differentiate structure and class in C++. 03

Page 17: GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER … · - Write the simple C++ programs using the variables, operators, control structures, functions and I/O objects cin and cout - Write

2

(b) Consider following class declarations.

class ABC;

class XYZ{

int x;

public:

void get_x(int i) {x=i;}

friend void sum(XYZ,ABC);

};

class ABC{

int y;

public:

void get_y(int i) {y=i;}

friend void sum(XYZ,ABC);

};

By considering above class declarations, define a function sum() at

outside the class to find out the sum of x and y and display the result.

Also define the main() which satisfy above class declarations.

04

(c) List out the characteristics of constructor in C++. Write a program to

illustrate the use of copy constructor. 07

Q.4 (a) Differentiate between late binding and early binding. 03

(b) Desribe different ways to open file with suitable example. 04

(c) Define polymorphism? How is it achieved in C++? Explain with

suitable example. 07

OR

Q.4 (a) Describe the syntax and use of set () function with suitable example. 03

(b) Explain virtual base class with a program. 04

(c) Demonstrate the use of static variables and static functions with a

program. 07

Q.5 (a) Describe the significance of this pointer with suitable example. 03

(b) Explain following file modes.

a. ios::app b. ios::out c. ios::binary d. ios::nocreate 04

(c) Define Exception? Explain Exception Handling Mechanism. Write a

program that demonstrates use of multiple catch. 07

OR

Q.5 (a) Explain pure virtual function with suitable example. 03

(b) Describe the various approaches by which we can detect the end of file

condition. 04

(c) Write a C++ program to copy the contents of a file A.txt into another

file B.txt. 07

*************

Page 18: GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER … · - Write the simple C++ programs using the variables, operators, control structures, functions and I/O objects cin and cout - Write

1

Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTER–IV (NEW) - EXAMINATION – SUMMER 2017

Subject Code: 2140705 Date: 12/06/2017 Subject Name: Object Oriented Programming With C++ Time: 10:30 AM to 01:00 PM Total Marks: 70 Instructions:

1. Attempt all questions. 2. Make suitable assumptions wherever necessary. 3. Figures to the right indicate full marks.

MARKS

Q.1 Short Questions 14

1 What is the full form of OOPS? 1

2 What is an object? 1

3 Define Data Abstraction. 1

4 What is a constructor? 1

5 What is the purpose of ‘delete’ operator? 1

6 Why do we need the preprocessor directive #include<iostream>? 1

7 Define Reusability. 1

8 What does this pointer point do? 1

9 Define std::cout and use it in a C++ statement. 1

10 What is the difference between an array and a simple variable? 1

11 How does a C++ Structure differ from a C++ Class? 1

12 Can We have more than one constructor in a Class? 1

13 Enlist Derived data types in C++. 1

14 How is a member function of a class defined? 1

Q.2 (a) Describe, with examples, the uses of enumeration data types. 3

(b) Explain the basic concepts of Object Oriented Programming. 4

(c) What is a User Defined Data type? What is the scope and life

time of variable? Explain using C++ program 07

OR

(c) Define a class complex with real and imaginary as two data

member, add necessary constructors and member function to

initialize and display data of class. Class should overload the +

operator to add two complex objects and return the results.

Invoke the statements like C3=C1+C2 in main ().

07

Q.3 (a) When do we declare a member of a class static? 03

(b) Describe the importance of destructors. 04

(c) Explain the type conversion from basic type to class type and

from class type to basic type with proper example. 07

OR

Q.3 (a) How many arguments are required in the definition of and

overloaded unary operator? 03

(b) When will you make a function inline? Why? 04

(c) By giving an example, illustrate use and working of nested try

blocks and re -throwing of an exception. 07

Q.4 (a) Describe the syntax of the single inheritance in C++. 03

(b) What is an abstract class? What is virtual base class? 04

(c) Explain Runtime polymorphism. Explain and demonstrate, how

virtual function to achieve runtime polymorphism? 07

OR

Q.4 (a) How do the I/O facilities in C++ differ form that in C? 03

(b) Explain reference variables. 04

(c) Declare a class called book having members like book_title,

publisher and author_name. Overload extractor and inserter 07

Page 19: GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER … · - Write the simple C++ programs using the variables, operators, control structures, functions and I/O objects cin and cout - Write

2

operators ( >> and << ) for class book.

Q.5 (a) Compare structured programming with object oriented

programming.. 03

(b) Discuss the different ways by which we can access public

member functions of an Object. 04

(c) Explain various file mode parameters in C++. Write a program to

copy the contents of a source file student1.txt to a destination file

student2.txt character by character.

07

OR

Q.5 (a) Describe the major parts of a C++ Program. 03

(b) Explain friend function with the help of an example 04

(c) What is an exception? What are the advantages of using

exception handling in a program? Illustrate C++ exception

handling mechanism

07

*************