POINTER AND REFERENCE TYPE
Pointer: A pointer is a variable which is used to store the address of another variable.
Pointer: A pointer is a variable which is used to store the address of another variable.
It is used to allocate memory dynamically at run time.
The pointer variable might be int, float, char, double, short etc.
Pointer syntax:
int *a;
Some points to remember about pointer:
- Pointer variable stores the address of the variable.
- The content of the pointer always be a whole number i.e. address.
- Pointer is initialized to null, i.e. int *a = null.
- The value of null pointer is 0.
- & symbol is used to get the address of the variable.
- * symbol is used to get the value of the variable whose address pointer is holding.
- Two pointers can be subtracted to know number of elements between these two pointers.
- Pointer addition, multiplication, division are not allowed.
Pointer example:
int main()
{
int *p, q;
q = 10;
p = &q;
return *p;
}
What are the design isuues with pointer type?
The design issues for pointer types are
- what the scope and lifetime of a pointer variable are,
- what the lifetime of a heap-dynamic variable (the value a pointer references) is,
- if pointers are restricted as to the type of value to which they can point,
- if pointers are used for dynamic storage management, indirect addressing, or both, and
- if the language should support pointer types, reference type, or both.
MCQs on Pointer and Reference type
Q1. Pointer is special kind of variable which is used to store __________ of the variable.
a. Value
b. Address
c. Variable Name
Q2. Pointer variable is declared using preceding _________ sign.
a. *
b. %
c. &
Q3. Address stored in the pointer variable is of type __________.
a. Integer
b. Character
c. Array
Q4. In order to fetch the address of the variable we write preceding _________ sign before variable name.
a. Comma
b. Ampersand
c. Asterisk
Q5. “&” is called as ___________ in pointer concept.
a. Address Operator
b. None of these
c. Conditional Operator
Q6. What do the following declaration signify?
char *arr[4];
a. arr is a array of 4 character pointers.
b. arr is a array of function pointer.
c. arr is a array of characters.
MCQs Answers
Q1. (b)
Q2. (a)
Q3. (a)
Q4. (b)
Q5. (a)
Q6. (a)
EasyExamNotes.com covered following topics in these notes.
Principles of Programming Languages:
EasyExamNotes.com covered following topics in these notes.
- Language Evaluation Criteria
- Influences on Language Design
- Language Categories
- Programming Paradigms
- Compilation
- Virtual Machines
- Programming Environments
- Issues in Language Translation
- Parse Tree
- Pointer and Reference type
- Concept of Binding
- Type Checking
- Strong typing
- Sequence control with Expression
- Exception Handling
- Subprograms
- Fundamentals of sub-programs
- Scope and lifetime of variable
- static and dynamic scope
- Design issues of subprogram and operations
- Local referencing environments
- Parameter passing methods
- Overloaded sub-programs
- Generic sub-programs
- Design issues for functions
- co routines
- Abstract Data types
- Abstraction and encapsulation
- Static and Stack-Based Storage management
- Garbage Collection
- OOP in C++
- OOP in Java
- OOP in C#
- OOP in PHP
- Concurrency
- Semaphores
- Monitors
- Message passing
- Java threads
- C# threads
- Exception handling
- Exceptions
- Exception Propagation
- Exception handler in C++
- Exception handler in Java
- Introduction and overview of Logic programming
- Basic elements of Prolog
- Application of Logic programming
- Functional programming languages
- Introduction to 4GL
Practicals:
- Memory Implementation of 2D Array.
- Memory Implementation of 3D Array.
- Implementation of pointers in C++.
- Write a program in Java to implement exception handling.
- Write a program in C++ to implement call by value parameter passing Method.
- Write a program in C++ to implement call by reference parameter passing Method.
- Write a program in Java to implement concurrent execution of a job using threads.
- Implement Inheritance in C#.
- Implement Encapsulation in C#.
- Implement static/compiletime Polymorphism in C#.
- Implement dynamic/runtime Polymorphism in C#.
Previous years solved papers:
A list of Video lectures
References:
- Sebesta,”Concept of programming Language”, Pearson Edu
- Louden, “Programming Languages: Principles & Practices” , Cengage Learning
- Tucker, “Programming Languages: Principles and paradigms “, Tata McGraw –Hill.
- E Horowitz, “Programming Languages”, 2nd Edition, Addison Wesley
- Memory Implementation of 2D Array.
- Memory Implementation of 3D Array.
- Implementation of pointers in C++.
- Write a program in Java to implement exception handling.
- Write a program in C++ to implement call by value parameter passing Method.
- Write a program in C++ to implement call by reference parameter passing Method.
- Write a program in Java to implement concurrent execution of a job using threads.
- Implement Inheritance in C#.
- Implement Encapsulation in C#.
- Implement static/compiletime Polymorphism in C#.
- Implement dynamic/runtime Polymorphism in C#.
Previous years solved papers:
A list of Video lectures
References:
- Sebesta,”Concept of programming Language”, Pearson Edu
- Louden, “Programming Languages: Principles & Practices” , Cengage Learning
- Tucker, “Programming Languages: Principles and paradigms “, Tata McGraw –Hill.
- E Horowitz, “Programming Languages”, 2nd Edition, Addison Wesley