10CS35 Data Structures with C/C++ Question Bank VTU 3th Semester

Leave a Comment
Sponsored Ads:
Sponsored Ads:
Visvesvaraya Technological University - VTU
Question Bank
(Regulation/Scheme 2010)
10CS35 Data Structures with C/C++
Third Semester - 3th
Computer Science Engineering - CSE
(Common to Information Science Engineering)

University Papers | Syllabus | Entrance Exam | Govt & PSU Papers | Bank Papers

Programming Questions | Travel Tips | Mobile Review | Placement Papers | Books



Download PDF File - Click Here

For More Question paper of CSE - CLICK HERE

For more question paper of ISE - CLICK HERE


1. What is a Pointer.Can we have multiple pointer to a variable? Explain Lvalue and
Rvalue expression. (10m)(June / July11),(dec 2010), (may/jun 2010)
A pointer is a variable whose value is the address of another variable ie. direct address of the
memory location. Like any variable or constant, you must declare a pointer before you can use it
to store any variable address. The general form of a pointer variable declaration is:
type *var-name;
Here, type is the pointer's base type; it must be a valid C data type and var-name is the name of
the pointer variable. The asterisk * you used to declare a pointer is the same asterisk that you use
for multiplication. However, in this statement the asterisk is being used to designate a variable as
a pointer. Following are the valid pointer declaration:
int *ip; /* pointer to an integer */
double *dp; /* pointer to a double */
float *fp; /* pointer to a float */
char *ch /* pointer to a character */
The actual data type of the value of all pointers, whether integer, float, character, or otherwise, is
the same, a long hexadecimal number that represents a memory address. The only difference
between pointers of different data types is the data type of the variable or constant that the
pointer points to.
How to use Pointers?
There are few important operations which we will do with the help of pointers very frequently.
(a) we define a pointer variables (b) assign the address of a variable to a pointer and (c) finally
access the value at the address available in the pointer variable. This is done by using unary
operator * that returns the value of the variable located at the address specified by its operand.
Following example makes use of these operations:
int main ()
int var = 20; /* actual variable declaration */
int *ip; /* pointer variable declaration */
ip = &var; /* store address of var in pointer variable*/
printf("Address of var variable: %x\n", &var );
/* address stored in pointer variable */

printf("Address stored in ip variable: %x\n", ip );
/* access the value using the pointer */
printf("Value of *ip variable: %d\n", *ip );
return 0;
Expressions that refer to memory locations are called "l-value" expressions. An l-value
represents a storage region's "locator" value, or a "left" value, implying that it can appear on the
left of the equal sign (=). L-values are often identifiers.
Expressions referring to modifiable locations are called "modifiable l-values." A modifiable lvalue
cannot have an array type, an incomplete type, or a type with the const attribute. For
structures and unions to be modifiable l-values, they must not have any members with the const
attribute. The name of the identifier denotes a storage location, while the value of the variable is
the value stored at that location.
An identifier is a modifiable l-value if it refers to a memory location and if its type is arithmetic,
structure, union, or pointer. For example, if ptr is a pointer to a storage region, then *ptr is a
modifiable l-value that designates the storage region to which ptr points.
Any of the following C expressions can be l-value expressions:
An identifier of integral, floating, pointer, structure, or union type
A subscript ([ ]) expression that does not evaluate to an array
A member-selection expression (–> or .)
A unary-indirection (*) expression that does not refer to an array
An l-value expression in parentheses
A const object (a nonmodifiable l-value)
The term "r-value" is sometimes used to describe the value of an expression and to distinguish
it from an l-value. All l-values are r-values but not all r-values are l-values.

2. Give atleast 2 differences between : i. Static memory allocation and dynamic
memory allocation.ii. Malloc() and calloc().(10m)(June / July11), (dec 2010)

3. Write a C program using pass by reference method to swap 2 characters.ii) Give
any 2 advantages and disadvantages of using pointers.(20m)( dec 2011)
//This program swaps the values in the variable using function containing reference arguments
void swap(int &iNum1, int &iNum2);
void main()
int iVar1, iVar2;
cout<<"Enter two numbers "<cin>>iVar1;
swap(iVar1, iVar2);
cout<<"In main "<}
void swap(int &iNum1, int &iNum2)
int iTemp;
iTemp = iNum1;
iNum1 = iNum2;
iNum2 = iTemp;
cout<<"In swap "<}
The main advantages of using pointers are
1.) Function cannot return more than one value. But when the same function can modify many
pointer variables and function as if it is returning more than one variable.
2.) In the case of arrays, we can decide the size of th array at runtime by allocating the necessary
3.) In the case of pointers to classes, we can use polymorphism and virtual classes to change the
behavior of pointers to various types of classes at runtime
The disadvantages of pointers
Data Structures with C 10CS35
Dept of CSE,knowledgeadda.com 5
1.) If sufficient memory is not available during runtime for the storage of pointers, the program
may crash (least possible)
2.) If the programmer is not careful and consistent with the use of pointers, the program may
crash (very possible)
A brief synopsis on the "rules" of pointers
1.) Always initialize a pointer by calling an allocator
2.) Alway check to see if the allocation request failed
3.) Always deallocate memory controlled by a pointer when done with it
4.) Never access memory that has not been allocated - pay attention to the size of arrays
5.) Never access memory that has been deallocated
6.) Do not allocate and deallocate memory with wild abandon, because that can fragment the
virtual memory address space, causing future allocation requests to fail - particularly in long
running programs such as web servers
4. What is an algorithm? Briefly explain the criteria that an algorithm must
satisfy.(10m)(dec 2012)
An algorithm is an effective method expressed as a finite list of well-defined instructionsfor
calculating a function Starting from an initial state and initial input (perhaps empty) the
instructions describe a computation that, when executed, proceeds through a finite number of

Search Related to 10CS35 Data Structures with C/C++

VTU BE syllabus 3th semester for 2010 Scheme
VTU Question Papers 3th semester
VTU Question Paper for third
Question Papers for CSE ISE VTU
10CS35 Data Structures with C/C++ vtu question papers
10CS35 Data Structures with C/C++ vtu notes
10CS35 Data Structures with C/C++ vtu notes
10CS35 Data Structures with C/C++ vtu syllabus
10CS35 Data Structures with C/C++ vtu notes 3th sem
10CS35 Data Structures with C/C++ notes vtu 3th sem ece


Post a Comment