Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

computer science,software engineering,c++

Rating
-
Sold
-
Pages
74
Uploaded on
06-03-2025
Written in
2024/2025

Introduction to Data Structures: Arrays, pointers, and structures. Stacks and Queues: Operations like push, pop, enqueue, and dequeue. Linked Lists: Singly, doubly, and circular linked lists. Trees: Binary trees, binary search trees (BST), tree traversal techniques. Graphs: Representation, BFS, DFS traversal. Sorting & Searching: Bubble sort, selection sort, quick sort, merge sort, and searching algorithms. Hashing and Hash Tables: Collision handling techniques.

Show more Read less
Institution
Course

Content preview

Object Oriented Programming in C++ 10CS36



UNIT -1: Introduction to C++


JUNE-JULY 2009

1a. Differentiate between procedure oriented and object oriented programming.
(06 marks)
 Procedure oriented programming divides the code into functions
 Data is not secure. It can be manipulated by any procedure.
 Compilers also do not prevent unauthorized functions from accessing/
manipulating structure variable.
 The code design is centered around procedures.
 OOPs ensure security of data.
 Interfaces perfectly manipulate the internal parts of the objects, with exclusive
rights.
 Functions logically related to data can only access the data, others can be
prevented from accessing the data members of the variables of this structure.
 This is achieved with the help of Data encapsulation in classes.
 Compile time errors against pieces of code are thrown which access unauthorized
data.
 Data can be grouped either as private or public data.

1b. Why should default values be given to function arguments in function
prototyping and not in function definition? Write a program to add three numbers
using function which has one or more default arguments. (09 marks)


C++ allows a function to assign a parameter a default value when no argument
corresponding to that parameter is specified in a call to that function. The default value is
specified in a manner syntactically similar to a variable initialization. For example, this
declares myfunc() as taking one double argument with a default value of 0.0:
void myfunc(double d =
0.0)
{
// ...
}
Now, myfunc() can be called one of two ways, as the following examples
show:
myfunc(198.234); // pass an explicit
value myfunc(); // let function use
default

When you are creating functions that have default arguments, it is important to remember
that the default values must be specified only once, and this must be the first time the
function is declared within the file. If you try to specify new (or even the same) default
values in function definition,

Dept of CSE, SJBIT 2

,Object Oriented Programming in C++ 10CS36



the compiler will display an error and not compile your program. Even though default
arguments for the same function cannot be redefined, you can specify different default
arguments for each version of an overloaded function

#include <iostream>
class example{
int x, y, z;
public:
example(int i=0, int j=0, int k=0) {
x=i;
y=j;
z=k;
}
Example(int i=10,int j=20)
{
y=I;z=j;
}
Example(int i=1)
{
z=I;
}

int add() {
return x+y+z;
}
};
int main()
{
example a(2,3,4), b(2),c(2,3);
cout << a.add() << endl;
cout << b.add();
cout<< c.add();
return 0;
}
1c. What is data abstraction. How it is implemented in C++. Explain with an example
(05 marks)
Data abstraction refers to, providing only essential features by
hiding its background details.
example:
class result
{
int marks;
float percentage;
char name[20]; void
input();
void output();
}

Dept of CSE, SJBIT 3

,Object Oriented Programming in C++ 10CS36



main()
{
bank b1;
b1.input();
b1.output();
}

in the above example, b1 is an object calling input and output member
functions, but that code is invisible to the object b1.




Dept of CSE, SJBIT 4

, Object Oriented Programming in C++ 10CS36




MAY/JUNE 2010

1a Explain the various features of object oriented programming (10 marks)
Essential features of object oriented programming

 Encapsulation
 Inheritance
 Polymorphism

Encapsulation in OOP-terminology means that an object has something like a shell
around it protecting the attributes or status variables from being accessed from outs ide of
the object. The belong to the object and to nobody else. Only the methods of the object
have access to them, can read and modify their values. The methods, providing the
services of the object, are the interface to the outside world.


Inheritance means that a derived class inherits all attributes and methods from its super
class, the class from which it is derived. This feature alleviates programmers from having
to start always from scratch when writing an object-oriented applications. Many times it
will be possible to design and implement a class that can be derived from existing ones in
some sort of class library, which one has either written oneself or that can be obtained
from another source.

Polymorphism in OOP-Terminology means that a certain message may be implemented
by different objects in different ways. A good example is the `display'-message sent to a
number, a string of characters or a list. It is always the message 'display yourself!'. The
object must know itself what has to be done and how, nobody cares as long as the object
appears on the screen.

1b. Discuss function prototyping, with an example. Also write its advantage (05
marks)
In C++ all functions must be declared before they are used. This is normally
accomplished using a function prototype. The use of parameter names is optional.
However, they enable the compiler to identify any type mismatches by name when an
error occurs, so it is a good idea to include them. It produces anThe function prototyping
tells the number of arguments,type of arguments and type of the return type to the
compiler.The function prototyping is a declaration statement in the calling program.

General Format:

returnType methodName(Argument List);

*Where Argument List specify the type and name of the arguments.



Dept of CSE, SJBIT 5

Written for

Institution
Course

Document information

Uploaded on
March 6, 2025
Number of pages
74
Written in
2024/2025
Type
Class notes
Professor(s)
Bheemanna khandre
Contains
Object oriented programming with c++

Subjects

$10.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
sangmeshdeggideggi

Get to know the seller

Seller avatar
sangmeshdeggideggi Self
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 year
Number of followers
0
Documents
3
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions