Download CBSE Class 12 Computer Science Pointers Notes in PDF format. All Revision notes for Class 12 Computer Science have been designed as per the latest syllabus and updated chapters given in your textbook for Computer Science in Class 12. Our teachers have designed these concept notes for the benefit of Class 12 students. You should use these chapter wise notes for revision on daily basis. These study notes can also be used for learning each chapter and its important and difficult topics or revision just before your exams to help you get better scores in upcoming examinations, You can also use Printable notes for Class 12 Computer Science for faster revision of difficult topics and get higher rank. After reading these notes also refer to MCQ questions for Class 12 Computer Science given on studiestoday
Revision Notes for Class 12 Computer Science Pointers
Class 12 Computer Science students should refer to the following concepts and notes for Pointers in Class 12. These exam notes for Class 12 Computer Science will be very useful for upcoming class tests and examinations and help you to score good marks
Pointers Notes Class 12 Computer Science
10, 20, 30, 40, 50,
10, 20, 30, 40, 50,
Note: A pointer variable can be used as an array as in above example both *p and p[0] refers to the same variable similarly b[0] and *b refers to the same variable. Again p[1] and *(p+1) are same.
Address calculation method is same for both pointer and array. For example int a[5]={2,4,6,7,9};
int *q=a;
The address of a[index] is calculated as
Base address of a (i.e. address of a[0]) + index * sizeof (data type of a)
for example if the base address of a is 1000 then address of a[3] is calculated as
&a[3] =1000 + 3 * sizeof (int) = 1000 + 3 * 2=1000 + 6 = 1006
Note that a[3] and *&a[3] both will give the same value i.e. 7
Similarly address of (q+3) is calculated as
Address stored in q + 3 * sizeof (data type of pointer belongs to in this case int) (q+3) = 1000 + 3 * sizeof (int) = 1000 + 3 * 2=1006
Arithmetic operation on pointers
We can increment or decrement a pointer variable for example float a[5]={3.0,5.6,6.0,2.5,5.3};
float *p=a;
++p;
--p;
if the base address of a is 1000 then statement ++p will increment the address stored in pointer variable by 4 because p is a pointer to float and size of a float object is 4 byte, since ++p is equivalent to p=p+1 and address of p+1 is calculated as
Address stored in p + 1 * sizeof (float)= 1000 + 1 * 4 = 1004.
We can add or subtract any integer number to a pointer variable because adding an integer value to an address makes another address e.g.
void main()
{int p[10]={8,6,4,2,1}; Int *q;
q=p;//address of p[0] is assigned to q assuming p[0] is allocated at memory location 1000 q=q+4;//now q contains address of p[4] i.e. 1000+4*sizeof(int)=1000+4*2= 1008
cout<<*q<<endl;
q=q-2;//now q contains address of p[2] i.e. 1008-2*sizeof (int)=1008-2*2=1004 cout<<*q<<endl;
}
Output is
1
4
Addition of two pointer variables is meaningless.
Subtraction of two pointers is meaningful only if both pointers contain the address of different elements of the same array
For example
void main()
{int p[10]={1,3,5,6,8,9};
int *a=p+1,*b=p+4;
p=p+q; //error because sum of two addresses yields an illegal address int x=b-a; //valid
cout<<x;
}
Output is
3
In the above example if base address of a is 1000 then address of a would be 1002 and address of b would be 1008 then value of b-a is calculated as
(Address stored in b-address stored in a)/sizeof(data type in this case int) (1008-1002)/2=3
Multiplication and division operation on a pointer variable is not allowed
We cannot assign any integer value other than 0 to a pointer variable. For example
int *p;
p=5; //not allowed
p=0; //allowed because 0 is a value which can be assigned to a variable of any data type
Null Pointer
A null pointer is a regular pointer of any pointer type which has a special value that indicates that it is not pointing to any valid reference or memory address. This value is the result of type-casting the
integer value zero to any pointer type.
int *q=0; // q has a NULL pointer value float * p;
p=NULL; // p has a NULL (NULL is defined as a constant whose value is 0) pointer value
Note: 0 memory address is a memory location which is not allocated to any variable of the program.
voidpointers
void pointer is a special pointer which can store address of an object of any data type. Since void pointer do not contain the data type information of the object it is pointing to we can not apply dereference operator * to a void pointer without using explicit type casting.
void main()
{
int x=5;
float y=3.5;
int *p;
float *q;
void *r;
p=&y; //error cannot convert float * to int * q=&x; //error cannot convert int * to float * p=&x; //valid
cout<<*p <<endl; //valid q=&y; //valid
cout<<*q<<endl ; //valid
r=&x; //valid
cout<<*r<<endl; //error pointer to cannot be dereference without explicit type cast cout<<*(int *)r<<endl; // valid and display the values pointed by r as int
r=&y; //valid
cout<<*(float *)r<<endl; //valid and display the values pointed by r as float
}
Note: Pointer to one data type cannot be converted to pointer to another data type except pointer to void
Array of pointers and pointer to array
An array of pointer is simply an array whose all elements are pointers to the same data type.
For example
Void main()
{
float x=3.5,y=7.2,z=9.7;
float *b[5]; // here b is an array of 5 pointers to float b[0]=&x;
b[1]=&y;
b[2]=&z;
cout<<*b[0]<<”\t”<<*b[1]<<”\t”<<*b[2]<<endl;
Please click the link below to download pdf file for CBSE Class 12 Computer Science - Pointers.
CBSE Class 11 Computer Science Computing and Binary Operation Notes |
CBSE Class 12 Computer Science Pointers Notes
We hope you liked the above notes for topic Pointers which has been designed as per the latest syllabus for Class 12 Computer Science released by CBSE. Students of Class 12 should download and practice the above notes for Class 12 Computer Science regularly. All revision notes have been designed for Computer Science by referring to the most important topics which the students should learn to get better marks in examinations. Our team of expert teachers have referred to the NCERT book for Class 12 Computer Science to design the Computer Science Class 12 notes. After reading the notes which have been developed as per the latest books also refer to the NCERT solutions for Class 12 Computer Science provided by our teachers. We have also provided a lot of MCQ questions for Class 12 Computer Science in the notes so that you can learn the concepts and also solve questions relating to the topics. We have also provided a lot of Worksheets for Class 12 Computer Science which you can use to further make yourself stronger in Computer Science.
You can download notes for Class 12 Computer Science Pointers for latest academic session from StudiesToday.com
Yes, the notes issued for Class 12 Computer Science Pointers have been made available here for latest CBSE session
There is no charge for the notes for CBSE Class 12 Computer Science Pointers, you can download everything free of charge
www.studiestoday.com is the best website from which you can download latest notes for Pointers Computer Science Class 12
Come to StudiesToday.com to get best quality topic wise notes for Class 12 Computer Science Pointers