0% found this document useful (0 votes)
8 views

Unit-1 Introduction to Pointer

The document provides an overview of pointers in programming, defining a pointer as a variable that holds the memory address of another variable. It discusses the advantages and disadvantages of pointers, the operators used with them, and how to declare and initialize pointer variables in C. Additionally, it covers pointer arithmetic, null pointers, and pointers to pointers, along with examples to illustrate their usage.

Uploaded by

espinozaden45
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Unit-1 Introduction to Pointer

The document provides an overview of pointers in programming, defining a pointer as a variable that holds the memory address of another variable. It discusses the advantages and disadvantages of pointers, the operators used with them, and how to declare and initialize pointer variables in C. Additionally, it covers pointer arithmetic, null pointers, and pointers to pointers, along with examples to illustrate their usage.

Uploaded by

espinozaden45
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

1020406104-Data Structures UNIT-1:Pointer By :Sneha Patel

 What is Pointer?

 Pointer is a variable which contains the address in memory of another variable.


we can have pointer in any variable type. The following drawing shows two variables:
num and numPtr. The simple variable num contains the value 42 in the usual way. The
variable numPtr is a pointer which contains a reference to the variable num. The numPtr
variable is the pointer and num is its point. What is stored inside of numPtr? Its value is not
an int. Its value is a reference to an int.

A simple int variable. The current


value is the integer 42. This variable
num 42 also plays the role of Pointe for the
pointer below.

A pointer variable. The current


numPtr value is a reference to the
Pointe num above.

EXAMPLE FOR POINTER:

int X = 547;
HERE
:
Variable name Content Location
s
X 547 4000

ptr 4000 4036

According to above figure, by the help of ptr variable we stored the address of variable X in
address 4036

 Pointers are used in following variables:-

 Variables of any basic data type


 An Array
 Functions
 Structures, and
 Unions

 Advantage of Pointer:-
1) Pointer can be used to return multiple values from function via arguments or parameters.
2) Pointer is easy to for handling array.
3) Pointer permits references to function and thereby facilitating passing of function as
arguments to other function.
4) Pointers array using to character string results in saving of data storage space in memory.
5) Pointers reduce length & complexity of program.
6) Pointers increase the execution speed & thus reduce the program execution time.
7) More compact and efficient coding
8) It support Dynamic memory Allocation
9) C uses pointers explicitly with: Array, Function & Structures.

BMU-BMCCA Page 1 of 15
1020406104-Data Structures UNIT-1:Pointer By :Sneha Patel

 Disadvantage of pointer:-

 If sufficient memory is not available during runtime for the storage of pointers, the program
may crash (least possible)

 Operators used with Pointers:-

1. The address operator: - & [ampersand]

“Address Operator” which gives or produces the memory address of data variable

2. The indirection operator: - ‘*’ [asterisk]

“Indirection operator or Dereferencing Operator" which provides the contents in the


memory location specified by a pointer

 Accessing the address of a variable:-

 The actual location of a variable is system depended and the address is not known to us
immediately. This can be done with the help of & (address operator) available in C.

 The operator & preceding a variable returns the address of a variable associated with it.

P = &i;

 This would assign the address 5000 to the variable P. when preceding the name of the
variable i with the reference operator (&) we are no longer talking about the content of the
variable p but about its reference (i.e. address in the memory)
 We declare a pointer variable we must point it to something we can do this by assigning to
the pointer the address of the variable you want to point as in the following example:
ptr = #
 This places the address where num is stores into the variable ptr. If num is stored in
memory 2101 address then the variable ptr has the value 2101

 Declare of Pointer Variable :-

 Pointer variables are declared just like any other variable. When pointer variable is
declared, the variable name must be preceded by an asterisk (*). This identifies that the
variable is a pointer.
 In ‘c’ Every Variable must be Declared its type ,since pointer variables contain address of
separate Data type , They must be Declared before use them the declaration of pointer
variable takes the following form
Syntax:

Data _type * pt_ name;

 Variable name is the name of the pointer variable, and data type refers to the data type of
the pointer’s object.
 Here are three things about the pointer variable:
 The asterisk (*) sign tells the variable pt_name is a pointer variable.
 Ptr_name needs a memory location.
 Ptr_name points to a variable of type data_type.

Example:
1. Int * p ; / * integer pointer */
2. float *ptr; /* float pointer */

HERE:
1. Declares the variable ‘p’ as a pointer variable that points to an integer data type
2. Declares the variable ‘ptr’ as a pointer variable that points to an ‘float’ data type
 There are three different ways to declare the pointer

int* p; / * style 1*/

BMU-BMCCA Page 2 of 15
1020406104-Data Structures UNIT-1:Pointer By :Sneha Patel

int *p; /* style 2*/


int * p; /*style 3*/

However, the style 2 is more popular due to following reasons;

1. This style is convenient to have multiple declarations in the same statement


Example:
int *p, x,*q ;

2. This style matches with the format used for accessing the target values.
Example:
int x, *p , y;
x=10;
y=*p;
*p = 20;

e.g.: int *numPtr; // Declare the int* (pointer to int) variable "numPtr".
// this allocates space for the pointer.

 Within a variable declaration, a pointer variable can be initialized by assigning it the


address of another variable. Remember that the variable is assigned whole address is
assigned to the pointer variable must have been declared earlier in the program.

Example for pointer declaration:-

# include < stdio.h>


void main ()
{
int var = 486;
int *ptr ;
ptr = &var;
printf(“ Address of var = %d\n”, ptr );
printf (“ The content of var = %d\n”, *ptr);
}

OUTPUT:
Address of var = 4056
The content of var = 486

 Initialization of Pointer Variable:-

 As ordinary variables are Initialized with in Declaration part of the program ,The Pointer
variables can initialized by Accessing address of the variable that are Used in the program .
 The initializer is a = (equal sign) followed by the expression that represents the address
that the pointer is to contain.
Syntax:
Data_type *ptr = expression

Where:
data_type = Any Basic Data type
*ptr = pointer variable
expression = another variable or may be constant
Example:
int quantity;
int *p ; /* Declaration */
p = &quantity; /* initialization*/
Here, the third line assigns the address of ‘quantity’ to pointer variable ‘p’

 We can’t assign the address of short integer or long integer

BMU-BMCCA Page 3 of 15
1020406104-Data Structures UNIT-1:Pointer By :Sneha Patel

 Initialization for array: The compiler converts an unsubscripted array name to a pointer
to the first element in the array. You can assign the address of the first element of an array
to a pointer by specifying the name of the array.
For example:
int array[20];
int *a=array;
is equivalent to:
int array[20];
int *a=&a[0];

 Initialization for String: You can assign the address of the first character in the string
constant to a pointer by specifying the string constant in the initializer.
For example
char *str=”abc”;
 The following example defines the fruits as a array of pointers to string constants. Each
element points to different string. The pointer fruits[1],for example , point to a string
“orange”.
char *fruits[]={“banana”,”orange”,”apple”,”mango” }
 A pointer can also be initialized to null using any integer constant expression that evaluates
to 0, for example char *a=0;. Such a pointer is a null pointer. It does not point to any
object.

 Invalid initializations:-

1. float a,b;
int x,* p;
p = &a; /* wrong */
b = *p;

Here, we will get erroneous output because we are trying to assign the address of float
variable to an integer variable it is not allowed in pointer assignments.

2. int *p = &x,x; /* wrong */

Here, it declares ‘x’ as integer variable, ‘p’ as pointer variable then assign
‘p’ to the address of ‘x’. First we must be declare the ‘x’ before initialization hence above
statement gives the erroneous output

Example for Pointer Initialization:

# include < stdio.h>


void main()
{
int m,*ptr;
m = 270;
ptr = & m;
printf (“ The content of variable ‘m’ = %d\n”,*ptr);
*ptr= 412; /* pointer initialization*/
printf(“ the content of the variable ‘m’ after initialization = %d\n”, *ptr);
getch();
}

0UTPUT:
The content of the variable ‘m’ = 270
The content of the variable ’m’ after initialization = 412

BMU-BMCCA Page 4 of 15
1020406104-Data Structures UNIT-1:Pointer By :Sneha Patel

More Examples for Pointer:

Example: 1 to display the value of a and b using pointer

#include <stdio.h>
Void main( ) 100 102
{ 102 3
int a=3,b; ptr a
int *ptr,*ptr1; // Pointer to an integer
ptr=&a; //assign address of a to ptr 200 202
b=*ptr; //assign the value of a
102 3
ptr1=&b; //assign the address of b to ptr1
ptr1=ptr; // assign the value of ptr to ptr1 b
ptr1
printf(“\n a=%d &a=%d *ptr=%d”,a,&a,*ptr);
printf(“\n b=%d &b=%d *ptr1=%d ptr1=%d”,b,&b,*ptr1,ptr1);
getch();
}

Example: 2 to display area of circle using pointer

#include <stdio.h>
#include <conio.h>
int main()
{
double radius=2.0,area;
double *pradius, *parea;
pradius=&radius;
parea=&area;
*parea= 3.14 * (*pradius) * (*pradius);
printf("%f", *parea);
getch();
}

 NULL Pointer:-

The constant NULL is a special pointer value which encodes the idea of "points to nothing."

num

The C language uses the symbol NULL for this purpose. NULL is equal to the integer
Constant 0, so NULL can play the role of a Boolean false.

 Rule or Operation on Pointer:-

1. A pointer variable can be assigned the address of an ordinary variable. (E.g. ptr=&a)
2. A pointer variable can be assigned the value of another variable (e.g. ptr=ptr1) provide
both pointers point to objects of the same data type.
3. A pointer variable can be assigned a null value. (E.g. ptr=NULL, where it represents the
value 0)
4. An integer quantity can be added to or subtracted from a pointer variable. (E.g. ptr++,
ptr+2 etc.)
5. One pointer variable can be subtracted from another provided both pointers point to
elements of the same array.
6. Two pointer variables can be subtracted from another provided both pointers point to
objects of the same type.

 Other arithmetic operations on pointers are not allowed. Thus, Pointer variable can not be
multiplied by a constant; two pointer variables can not be added; and so on.

BMU-BMCCA Page 5 of 15
1020406104-Data Structures UNIT-1:Pointer By :Sneha Patel

Example: Two different pointer variables point to the first & last elements of an integer array.

#include<stdio.h> Memory
Location
main()
{ 1 2
int *ptr,*ptr1;
int a[6]={1,2,3,4,5,6}; 2 4
ptr=&a[0];
3 6 12-2=10
ptr1=&a[5];
printf(“\n The value of 2 pointers are :%d”, ptr,ptr1); 10/2=5
4 8
printf(“\n subtraction is (ptr1-ptr)=%d”, ptr1-ptr);
getch(); 5 10
} Size of data type
6 12
Output:-
The value of 2 pointers are:ptr=2 ptr1=12 Write This Statement instead of ptr1-ptr
Subtraction is (ptr1-ptr) =5

printf(“\n subtraction is (ptr1-ptr)=%d”, ptr1+ptr);

 Here we can write statement like ptr1+ptr than it generate the error Illegal pointer addition.

 Pointer to Pointer (Multiple Indirection)

 Pointer point to another pointer that points to the target value.


Pointer Variable

Address Value

[Single Indirection]

 The value of normal pointer is the address of object that contains the desire value.

Pointer Pointer Variable

Address Address Value

[Pointer to Pointer]

 In pointer to pointer, the first pointer contains the address of the second pointer, which
points to the object that contains the desired value.

 The declaration of pointer to pointer is, (use additional asterisk in front of the variable
name)
Syntax:
Data_type **ptr

Example:
#include <stdio.h>
int main(void)
{
int x,*p,**q;
x=10;
p=&x;
q=&p;
printf(“%d\n”, **q);
getch()
}

BMU-BMCCA Page 6 of 15
1020406104-Data Structures UNIT-1:Pointer By :Sneha Patel

 Arithmetic and Logical Operations on Pointers :-

 Pointers are valid operands in arithmetic expressions, assignment expressions and


comparison expressions. However, not all the operators normally used in these expressions
are valid with pointer variables.
 Several arithmetic operations may be performed on pointers. A pointer may be incremented
(++) or decremented (--), an integer may be added to a pointer (+ or +=), an integer may
be subtracted from a pointer (- or -=) or one pointer may be subtracted from another.
 Arithmetic operations can be performed on pointers
 Increment/decrement pointer (++ or --)
 Add an integer to a pointer( + or += , - or -=)
 Pointers may be subtracted from each other
 Operations meaningless unless performed on an array
 5 element int array on machine with 4 byte ints
 vPtr points to first element v[ 0 ]
 at location 3000 (vPtr = 3000)
 vPtr += 2; sets vPtr to 3008
 vPtr points to v[ 2 ] (incremented by 2), but the machine has 4 byte ints, so it points
to address 3008
location
3000 3004 3008 3012 3016

v[0] v[1] v[2] v[3] v[4]

Pointer variable vPtr

 Passing Pointer to Function

 Pointers can be used to pass addresses of variables to called functions, thus allowing the
called function to alter the values stored there.
 We looked earlier at a swap function that did not change the values stored in the main
program because only the values were passed to the function swap.
 This is known as "call by value".
 If instead of passing the values of the variables to the called function, we pass their
addresses, so that the called function can change the values stored in the calling
routine.This is known as "call by reference" since we are referencing the variables.
 The following shows the swap function modified from a "call by value" to a "call by
reference". Note that the values are now actually swapped when the control is returned to
1main function.
Pointers with Functions (Examples)

Example1:

#include <stdio.h> void swap( int *a, int *b )


void swap( int *a, int *b); {
void main ( ) int temp;
{ temp= *a;
int a = 5, b = 6; *a= *b;
printf("a=%d b=%d\n",a,b); *b = temp ;
swap (&a, &b); //call by reference printf ("a=%d b=%d\n", *a, *b);
printf("a=%d b=%d\n",a,b); }
getch(); Output:
} a=5 b=6
a=6 b=5
a=6 b=5

BMU-BMCCA Page 7 of 15
1020406104-Data Structures UNIT-1:Pointer By :Sneha Patel

Example2:

#include<stdio.h>
#include<conio.h>
void calc(int x, int y, int *add, int *sub)
{
*add = x+y;
*sub = x-y;
}
void main()
{
int a=20, b=11, p,q;
clrscr();
calc(a,b,&p,&q);
printf("Sum = %d, Sub = %d",p,q);
getch();
}

 Pointer and Array

 One Dimensional Array:-

 Array name is pointer to the first element in the array. Therefore, if a is a one
dimensional array, then the address of the first array element can be expressed as either
&a[0] or simply as a. the address of second array element can be written as either &a[1]
or as (a+1) and so on. In general, the address of array element (i+1) can be expressed
as either &a[i] or as (a+i).
 We have two different ways to write the address of any array element:
 We can write the actual element preceded by ampersand. e.g. &a[i]
 We can write an expression in which the subscript is added to the array name like (a+i)
 If numerical array is defined as pointer variable, the array elements can not be assigned
inital values.
 A character type pointer variable can be assigned an entire string as a part of the variable
declaration. Thus, a string can be represented by either a one dimensional character
array or a character pointer.

Example: To display the array element using pointer

#include<stdio.h>
void main()
{
inti,n, *pa;
printf("Input the value of N\n");
scanf("%d", &n);
pa=(int*)malloc(n*sizeof(int)) ;
printf("Input %d values\n", pa);
for(i=0;i<n;i++)
{

scanf("%d", (pa+i));
}
printf("\n print array using dynamic pointer\n");
for(i=0;i<n;i++)
{
printf(“%d -- %d\n",(pa+i),*(pa+i));
}
}

BMU-BMCCA Page 8 of 15
1020406104-Data Structures UNIT-1:Pointer By :Sneha Patel

 Multidimensional Array:-

 A Two Dimensional Array is actually collection of one dimensional array. Therefore, we


can define a two dimensional array as a pointer to a group of contiguous one dimensional
array. Thus a two dimensional array declaration can be written as

Data type (*ptr)[expression 2];

 rather than

Data type array[expression 1][expression 2];

 Example: a is defined to be a group of contiguous, one dimensional 10 element integer


arrays. Thus a point to the first 10 element array, which is actually the first row of the
original two dimensional arrays. Similarly, (a+1) points to the second 10 elements array,
which is the second row of the original two dimensional array and so on.

 An individual array element within a multidimensional array can be accessed by the


repeated use of the indirection operate. The following example, the item in row 2, column
5 can be accessed by writing either a[2][5] or *(*(a+2)+5). Where (a+2) is a pointer to
row 2. *(a+2) is actually a pointer to the first element in row 2. (*(a+2) + 5) is a pointer
to element 5 in row 2.*(*(a+2) + 5) refers to the value of element 5 in row 2.

Example: write a program to input the elements of 2 matrix and display in table form.

#include<stdio.h>
void input(int *a[3],int row,int col);
void display(int *a[3],int row,int col);
void main()
{
int *a[3],*b[3],r,c,row;
printf(“Enter the No Of Rows:”);
scanf(“%d”,&r);
printf(“Enter the no of column:”);
scanf(“%d”,&c);
//allocate the initial memory
for(row=0;row<r;row++)
{
a[row]=(int *)malloc(c*sizeof(int));
b[row]=(int *)malloc(c*sizeof(int));
}
//First matrix
input(a,r,c);
display(a,r,c);
//Second marix
input(b,r,c);
display(b,r,c);
getch();
}
void input(int *a[3],int i,int j)
{
int r,c;
for(r=0;r<i;r++)
{
for(c=0;c<j;c++)
{
sacnf(“%d”,(*(a+r)+c));
}
}

BMU-BMCCA Page 9 of 15
1020406104-Data Structures UNIT-1:Pointer By :Sneha Patel

void display(int *a[3],int i,int j)


{
int r,c;
for(r=0;r<i;r++)
{
for(c=0;c<j;c++)
{
printf(“%d”,*(*(a+r)+c));
}
}
}

 Array of Pointer:-

 A multidimensional array can be expressed in terms of an array of pointers rather than a


pointer to a group of contiguous arrays. In such situations the newly defined array will have
one less dimension than the original multidimensional array. Each pointer will indicate the
beginning of a separate (n-1) dimensional array.
 In general terms, a two dimensional array can be defined as a one dimensional array of
pointers by writing

Syntex:
Data type *array[expression 1]

Rather than the conventional array definition

Data type array[expression 1][expression 2]

 An n-dimensional array can be defined as an (n-1) dimensional array of pointer by writing

Data type *array[expression 1]. . . . . [expression n-1]

 The array name and its preceding asterisk are not enclosed in parentheses in this type of
declaration. Thus, a right to left rule first associates the pairs of square brackets with array,
defining the named object as an array. The preceding asterisk then establishes that the
array will contain pointers.
 Suppose a is a two dimensional array having 3 rows and 3 columns, as we define a as a one
dimensional array of pointers by writing

int *a[3];
rather than
int a[3][3];

 a[0] points to the beginning of the first row, a[1] points to the beginning of the second row.
An individual array element, such as a[2][5],can be accessed by writing

*(a[2]+5)

Example: WAPT calculate the sum of two matrixes.

#include<stdio.h>
void input(int *a[3],int row,int col);
void display(int *a[3],int row,int col);
void add(int *a[3],int *b[3],int *sum[3],int row,int col);

main()
{
int *a[3],*b[3],*sum[3],r,c,row;
printf(“Enter the No Of Rows:”);

BMU-BMCCA Page 10 of 15
1020406104-Data Structures UNIT-1:Pointer By :Sneha Patel

scanf(“%d”,&r);
printf(“Enter the no of column:”);
scanf(“%d”,&c);
//allocate the initial memory
for(row=0;row<r;row++)
{
a[row]=(int *)malloc(c*sizeof(int));
b[row]=(int *)malloc(c*sizeof(int));
sum[row]= (int *)malloc(c*sizeof(int));
}

//First matrix
input(a,r,c);
display(a,r,c);
//Second matrix
input(b,r,c);
display(b,r,c);
//sum of two matrix
add(a,b,sum,r,c);
display(sum,r,c);
getch();
}
void input(int *a[3],int i,int j)
{
int r,c;
for(r=0;r<i;r++)
{
for(c=0;c<j;c++)
{
sacnf(“%d”,(a[r]+c));
}
}
}
void display(int *a[3],int i,int j)
{
int r,c;
for(r=0;r<i;r++)
{
for(c=0;c<j;c++)
{
printf(“%d”,*(a[r]+c));
}
}
}
void add(int *a[3],int *b[3], int *sum[3],int i,int j)
{
int r,c;
for(r=0;r<i;r++)
{
for(c=0;c<j;c++)
{
*(sum[r]+c)=*(a[r]+c) + *(b[r]+c);
}
}
}

BMU-BMCCA Page 11 of 15
1020406104-Data Structures UNIT-1:Pointer By :Sneha Patel

 Pointer to Array:-
 If we can have a pointer to an integer, a pointer to a float, a pointer to a char, then can we
not have a pointer to an array? We certainly can. The following program shows how to build
& use it.

/* Usage of pointer to an array */


main( )
{
int s[5][2] ={ { 1234, 56 }, { 1212, 33 }, { 1434, 80 }, { 1312, 78 } } ;
int ( *p )[2] ;
int i, j, *pint ;
for ( i = 0 ; i <= 3 ; i++ )
{
p = &s[i] ;
pint = p ;
printf ( "\n" );
for ( j = 0 ; j <= 1 ; j++ )
printf ( "%d ", *( pint + j ) ) ;
}
}
And here is the output...
1234 56
Here p is a pointer to an array of two integers. Note that the parentheses in the
declaration of p are necessary.

 Pointer and Structure:-

C allows pointer to structures. There are two primary uses for structure pointers:

1) To pass a structure to a function using call by reference


2) To create linked lists and other dynamic data structure tat rely on dynamic allocation

 When a pointer to structure is passed to a function, only the address of the structure is
pushed on the stack. This makes for very fast function calls.
 Second advantage is that passing pointer makes it possible for the function to modify the
contents of the structure used as the argument.
 Structure pointers are declared by placing * in front of structure variable’s name.

struct structure_variable *ptr_variable_name;


OR
struct structure _name structure_variable , *ptr_vriable;

 Where data type is identifies the composition of the structure, and ptr represents the name
of the pointer variable. We can then assign the beginning address of a structure variable to
this pointer by writing

ptr_variable=&structure_variable;

struct employee
{
int ano;
char name[30];
}emp;

struct employee *e; // declare a structure pointer

OR

struct employee

BMU-BMCCA Page 12 of 15
1020406104-Data Structures UNIT-1:Pointer By :Sneha Patel

{
int ano;
char name[30];
};
struct employee emp, *e; // declare a structure pointer

This places the address of the structure emp into the pointer e;

e=&emp;

 To access the members of a structure using a pointer to that structure, you must ( )
use the Operator

ptr_variable member name

e.g.: e ano

 The -> operator can be combined with the period operator to access a submember within a
structure. A submember can be accessed by writing

ptr_variable member_name.submember_name

Here is the code:


#include <stdio.h>
#include <conio.h>
int main()
{
struct st
{
int id;
char *name;
char *address;
};
struct st employee, *stptr;
stptr = &employee;
stptr->id = 1;
stptr->name = "Angelina";
stptr->address ="Rohini,Delhi";
printf("Employee Information: id=%d\n%s\n%s\n",
stptr->id, stptr->name, stptr->address);
getch();
return 0;
}

Example: WAP to display the student information


struct student
{
int no;
char name[30];
float per;
};
void main()
{
struct student stud, *s; /*define the structure */
s=&stud; /*a pointer to a structure*/
void input(struct student *s);
void display(struct student *s);
input(&s); or input(s);
display(&s);or display(s);
getch();
}
Void input(struct student *s)
{
printf(“Roll No”);

BMU-BMCCA Page 13 of 15
1020406104-Data Structures UNIT-1:Pointer By :Sneha Patel

scanf(“%d”,&s->no);
printf(“Name”);
scanf(“%s”,s->name);
printf(“Per”);
scanf(“%f”,&s->per);
}
Void display(struct student *s)
{
printf(“roll no=%d”,&s->no);
Printf(“Name=%s”,s->name);
printf(“Per=%f”,s->per);
}

Question Bank
 Short Question (Marks-2)

1. Differentiate between * and ** operators.


2. How to initialize pointer?
3. How to increment value of a variable using pointer? Give example.
4. What do you mean by pointer to pointer?
5. What is pointer? Give one example.
6. What is the significance of ‘*’ and ‘&’ operator?
OR
Explain value and address operator.
7. Notes on operation on pointer.
8. What is difference between int *a[5](aaray of pointer) and int (*a)[5](pointer to
array).
9. What is the difference between character array and a character pointer?

 Long Question: (marks-5-7)

1. What is pointer? Write note on pointer arithmetic.


OR
Explain arithmetic operation on pointers.
2. What is pointer? Explain Advantages and disadvantages of pointer.
3. Define Pointer. Explain accession, declaration and initialization of pointer.
OR
Short note: Pointer.
OR
Explain concept of Pointer.
4. Is it possible to create array by using pointer? justify.(array of pointer)
5. Is it possible to declare pointer within structure? (structure pointer)
6. Explain with example passing pointer as function argument.
7. What is dynamic memory allocation? Explain various functions that are used to
allocate memory dynamically.
8. Nesting of function.
9. Explain Pointer to Array.

BMU-BMCCA Page 14 of 15
1020406104-Data Structures UNIT-1:Pointer By :Sneha Patel

BMU-BMCCA Page 15 of 15

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy