APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY Previous Years Question Paper & Answer

Course : B.Tech

Semester : S1 and S2

Year : 2017

Term : DECEMBER

Branch : BIOTECHNOLOGY

Scheme : 2015 Full Time

Course Code : CS 100

Page:26





PDF Text (Beta):

Benefit of using pointers

« Pointers are more efficient in handling Array and Structure.

Pointer ‘allows references to function and thereby helps in passing of function as
arguments to other function

We can access the value 10 by either using the variable name a or the address 80F. Since the memory
addresses are simply numbers they can be assigned to some other variable. The variable that holds
memory address are called pointer variables. A pointer variable is therefore nothing but a variable
that contains an address, which is a location of another variable. Value of pointer variable will be
stored in another memory location. General syntax of pointer declaration is, data-type *pointer_name;
inta=10;
int *ptr ; //pointer declaration
ptr = &a; //pointer
initialization or,
int *ptr=&a; //initialization and declaration together

Dereferencing of Pointer
Once a pointer has been assigned the address of a variable. To access the value of variable, pointer
is dereferenced, using the indirection operator *. int a,*p; a= 10;
p= &a;

printf("%d",*p); /this will print the value of a.
printf("%d",*&a); /this will also print the value

of a. printf("%u",&a); //this will print the address

b) write a program in C to store ೧ elements in an array and print the elements using pointer
of a. printf("%u",p); //this will also print the

address of a. printf("%u" ,&p); /this will also print

the address of p.

#include
int main()

{

int arr1[25], i,n;

printf("\n\n Pointer : Store and retrieve elements from an array :\n");
0117 ("------------------------------------------------------------ \n");
printf(" Input the number of elements to store in the array :");

5೦೩೧೫ ("%Sd",&n);

printf(" Input %d number of elements in the array :\n",n);
for (2-0 1:൩2)

Similar Question Papers