Programming in C++ and Data Structures
Time :2 Hrs (11.00 am to 01.00 pm) Max. Marks :50
Section A (10x 2= 20)
(Answer any TEN questions)
1. Write the syntax for variable declaration with an example.
A variable is a name given to a memory location. It is the basic unit of storage in a
program. Syntax
type variable_name;
2. Define: Scope operator
The :: (scope resolution) operator is used to get hidden names due to variable scopes
so that you can still use them.
3. When do you use friend function?
A friend class can access private and protected members of other class in which it is
declared as friend. a friend function can be given special grant to access private and
protected members. A friend function can be:
a) A method of another class
b) A global function
4. What are the operators cannot be overloaded?
Scope Resolution Operator (::)
Pointer-to-member Operator (.*)
Member Access or Dot operator (.)
Ternary or Conditional Operator (?:)
5> Object size Operator (sizeof)
6> Object type Operator (typeid)
5. What is Destructor?
Destructor is a member function which destructs or deletes an object.
Syntax:
~constructor-name();
6. Mention any four keywords in C++.
auto, break, case, int
7. What is meant by order list?
The structure of an ordered list is a collection of items where each item holds a
relative position that is based upon some underlying characteristic of the item. Eg:
Stack, Queue, Linked List.
8. Define prefix notation, infix notation, postfix notation
Infix notation: X + Y Operators are written in-between their operands.
Postfix notation: X Y + Operators are written after their operands.
Prefix notation: + X Y Operators are written before their operands.
9. Write the postfix and prefix expression ((A+B)*(C-D))/(P-R)
AB+CD-*PR-/
10. What is the push in stack?
Inserting an element into a stack is called push
11. List out the use of singly linked list
Dynamic memory allocation: We use linked list of free blocks.
Maintaining directory of names
Performing arithmetic operations on long integers
12. State the application of queue
1. When a resource is shared among multiple consumers. Examples include CPU
scheduling, Disk Scheduling.
2. When data is transferred asynchronously (data not necessarily received at same
rate as sent between two processes. Examples include IO Buffers, pipes, file IO, etc.