adplus-dvertising
Perfect 24 U
No Result
View All Result
  • Home
  • KPK NOTES
    • KPK TextBook Board
      • Grade 1
      • Grade 2
      • Grade 3
      • Grade 4
      • Grade 5
      • Grade 6
      • Grade 7
      • Grade 8
      • Grade 9
      • Grade 10 KPTBB BOOK
      • Grade 12 books for KPK
      • Grade 11 BOOK KPK Board
    • Class 7
      • Urdu
    • Class 9
      • Mathematics
      • English Class 9 Notes for KPK
      • 9th Urdu Notes
      • Biology 9th
      • Islamiat 9
      • Computer Science 9th
      • Pak Studies 9
      • Physics 9th
      • Chemistry 9th
    • Class 10
      • English 10th Notes
      • Biology 10 Class
      • CHEMISTRY 10 NOTES
      • class 10 Maths
      • Pak Study 10th
      • Physics 10
      • Urdu 10
    • Class 11 KPK Notes
      • 11 class biology notes KPK
      • 1st Year Mathematics Notes
      • chemistry class 11 notes
      • English FA Fsc Part 1 KPK
      • Islamiat Class 11 for kpk
      • Physics class 11 notes
    • 2nd Years
      • 2nd Year Chemistry Notes
      • Mathematics-XII
      • 2nd year computer science notes
      • 2nd Year Economics Notes
      • 2nd year English notes
      • 2nd year Pakistan Study Notes
      • 2nd Year Physics Notes
      • Bio Fsc Part 2
    • BISE Swat
      • Result
      • Model Papers
      • Chemistry Class 10 Notes
      • Class 11 Computer Science
      • Economics Notes Class 11
      • Statistics Class 11
      • Class 12 Statistics Notes
    • Syllabus
    • Mardan Board
      • 9th Notes
  • AIOU
    • B.ED books
    • B.S AIOU Books
    • Bachelor AIOU Books
    • CT AIOU Books
    • FA
  • BISE Lahore
    • Class X
      • English Class 10th Notes
    • Class IX
      • English Class 9th Notes
    • Class XI
      • English Class 11th Notes
    • Class XII
      • English Class 12th Notes
  • Sindh Board
    • Sindh Textbook Jamshoro
    • Class IX
      • Pak Studies Sindh 9
      • Computer Science 9 Sindh
      • Mathematic Sindh Class 9
      • Chemistry Notes
      • Biology 9
      • Physics
      • Sindh Board English 9th Notes
      • Islamiat Class 9 Sindh
    • Class X
      • Sindh Class 10 Physics
      • Sindh Class 10th English Notes
      • Islamiat Class 10 Sindh
    • Class XI
      • Islamiat
      • English notes class 11 Sindh board
    • Class XII
      • English Notes Sindh board 12th
  • CBSE
    • CBSE Class 9
    • CBSE Class 10
    • CBSE Class 11
    • CBSE Class 12
  • Rawalpindi Board
    • Class 9th
      • English 9th Notes
      • Biology G9
    • Class 10th
      • English 10th Notes
    • Class 11th
      • English 11th Notes
  • FBISE
    • 9 Class
      • Computer Science
      • Biology Notes
      • 9th FBISE Maths
      • Fbise 9 Notes Eng
    • 10 Class
      • English FBISE Notes
    • 11 Class
      • FBISE English 11th
    • 12 Class
      • Class 12 English Notes Fbise
    • FBISE Past Papers
      • 10 Class
      • 9th Past Papers
  • Articles
    • Essay
    • A-Z Universities in Pakistan
    • Admissions
    • All Country Independence Day
    • Countries Info
    • FILMORA
    • Education Qoutes
    • Happy Teacher Day
    • Insurance
    • Islamic
    • Muslim Boys names
    • Nelson’s Mandela
    • PHILONTHROPIC PRACTICES
    • Speeches
    • Story
  • DIT
  • DAE
  • MCQs
  • Technology
    • Marketing Think with Google
    • Science
  • Punjab board
    • Class 11 Notes PTBB
      • Computer Science PTBB Class 11
      • English 11 Notes Punjab
      • Chemsitry PTBB 11th
      • Math Notes PTBB 11th
      • Physics PTBB 11th
      • Urdu PTBB 11th
      • Biology 11th PTBB
    • Class 9
    • Punjab Class 10th
    • Punjab Board Class 10 Chemistry
  • Home
  • KPK NOTES
    • KPK TextBook Board
      • Grade 1
      • Grade 2
      • Grade 3
      • Grade 4
      • Grade 5
      • Grade 6
      • Grade 7
      • Grade 8
      • Grade 9
      • Grade 10 KPTBB BOOK
      • Grade 12 books for KPK
      • Grade 11 BOOK KPK Board
    • Class 7
      • Urdu
    • Class 9
      • Mathematics
      • English Class 9 Notes for KPK
      • 9th Urdu Notes
      • Biology 9th
      • Islamiat 9
      • Computer Science 9th
      • Pak Studies 9
      • Physics 9th
      • Chemistry 9th
    • Class 10
      • English 10th Notes
      • Biology 10 Class
      • CHEMISTRY 10 NOTES
      • class 10 Maths
      • Pak Study 10th
      • Physics 10
      • Urdu 10
    • Class 11 KPK Notes
      • 11 class biology notes KPK
      • 1st Year Mathematics Notes
      • chemistry class 11 notes
      • English FA Fsc Part 1 KPK
      • Islamiat Class 11 for kpk
      • Physics class 11 notes
    • 2nd Years
      • 2nd Year Chemistry Notes
      • Mathematics-XII
      • 2nd year computer science notes
      • 2nd Year Economics Notes
      • 2nd year English notes
      • 2nd year Pakistan Study Notes
      • 2nd Year Physics Notes
      • Bio Fsc Part 2
    • BISE Swat
      • Result
      • Model Papers
      • Chemistry Class 10 Notes
      • Class 11 Computer Science
      • Economics Notes Class 11
      • Statistics Class 11
      • Class 12 Statistics Notes
    • Syllabus
    • Mardan Board
      • 9th Notes
  • AIOU
    • B.ED books
    • B.S AIOU Books
    • Bachelor AIOU Books
    • CT AIOU Books
    • FA
  • BISE Lahore
    • Class X
      • English Class 10th Notes
    • Class IX
      • English Class 9th Notes
    • Class XI
      • English Class 11th Notes
    • Class XII
      • English Class 12th Notes
  • Sindh Board
    • Sindh Textbook Jamshoro
    • Class IX
      • Pak Studies Sindh 9
      • Computer Science 9 Sindh
      • Mathematic Sindh Class 9
      • Chemistry Notes
      • Biology 9
      • Physics
      • Sindh Board English 9th Notes
      • Islamiat Class 9 Sindh
    • Class X
      • Sindh Class 10 Physics
      • Sindh Class 10th English Notes
      • Islamiat Class 10 Sindh
    • Class XI
      • Islamiat
      • English notes class 11 Sindh board
    • Class XII
      • English Notes Sindh board 12th
  • CBSE
    • CBSE Class 9
    • CBSE Class 10
    • CBSE Class 11
    • CBSE Class 12
  • Rawalpindi Board
    • Class 9th
      • English 9th Notes
      • Biology G9
    • Class 10th
      • English 10th Notes
    • Class 11th
      • English 11th Notes
  • FBISE
    • 9 Class
      • Computer Science
      • Biology Notes
      • 9th FBISE Maths
      • Fbise 9 Notes Eng
    • 10 Class
      • English FBISE Notes
    • 11 Class
      • FBISE English 11th
    • 12 Class
      • Class 12 English Notes Fbise
    • FBISE Past Papers
      • 10 Class
      • 9th Past Papers
  • Articles
    • Essay
    • A-Z Universities in Pakistan
    • Admissions
    • All Country Independence Day
    • Countries Info
    • FILMORA
    • Education Qoutes
    • Happy Teacher Day
    • Insurance
    • Islamic
    • Muslim Boys names
    • Nelson’s Mandela
    • PHILONTHROPIC PRACTICES
    • Speeches
    • Story
  • DIT
  • DAE
  • MCQs
  • Technology
    • Marketing Think with Google
    • Science
  • Punjab board
    • Class 11 Notes PTBB
      • Computer Science PTBB Class 11
      • English 11 Notes Punjab
      • Chemsitry PTBB 11th
      • Math Notes PTBB 11th
      • Physics PTBB 11th
      • Urdu PTBB 11th
      • Biology 11th PTBB
    • Class 9
    • Punjab Class 10th
    • Punjab Board Class 10 Chemistry
Perfect 24 U
No Result
View All Result
Home KPK NOTES 2nd Years 2nd year computer science notes

2nd Year Computer Science Notes Chapter 7 Pointers

ADVERTISEMENT

KPK Grade 12 Computer Science Computer Science Notes Pointers

Table of Contents

  • KPK Grade 12 Computer Science Computer Science Notes Pointers
  • Q.4) Define the term pointer. Describe the advantages of using pointer variables.
  • Q.5) What is the difference between the deference  operator* and reference operator &?  Explain with the help of some lines of code.
  • Q.6) What is meant by the term pointer initialization? Write a simple program to illustrate this concept.
  • Q.7) How the declaration of a pointer variable is different from the declaration of a variable.

Q.4) Define the term pointer. Describe the advantages of using pointer variables.

POINTERS DEFINITION:
“The variable that stores the address of another variable”
EXPLANATION:
Pointers are powerful features of C++ that differentiate it from other programming languages. With the help of pointers, C++ gives users the power to manipulate the data in the computer’s memory directly. Pointers are used in the C++ program to access the memory and manipulate the address.

Class 12th notes for computer sceince for kpk

he variable name refers to that memory space that is occupied by it. Pointers are used to store the address of a variable. The width of the memory address/location depends on computer architecture. If the computer architecture is 16-bit then it means that it can have 216 memory locations.

Therefore, for a pointer to be able to store any memory location in this computer it should be 16 bits or 2 bytes wide. Similarly, for 32-bit and 64-bit architecture, we need to have pointers with size 4 bytes (32-bit width) and 8 bytes (64-bit width) respectively.
ADVANTAGE OF POINTER VARIABLE
The main advantages of pointers are as follows:

  • It can save memory (Pointers reduce the length and complexity of a program)
  • It runs faster because it does not have to duplicate the data. They increase execution speed.
  • A pointer enables us to access a variable that is defined outside the function.
  • Pointers are more efficient in handling the data tables.
  • The use of a pointer array of character strings results in saving of data storage space in memory.

Q.5) What is the difference between the deference  operator* and reference operator &?  Explain with the help of some lines of code.

DIFFERENCE BETWEEN DEREFERENCE AND REFERENCE OPERATOR DEREFERENCE OPERATOR (*)
PURPOSE:

If we want to store the value of the variable through the pointer, then we need a special type of operator called dereference operator denoted by an asterisk (*).


EXAMPLE:
Consider the following program to demonstrate the use of dereference operator (*).
#include <iostream.h>
#include<conio.h>
int main()
{
int n = 200;
int *Pn; //defines a pointer to n
Pn=&n; //Pn stores the address of ‘n’
int valueN;
valueN=*Pn;
cout << “The address of n= ”<<&n << endl;
cout<< “The value of n= ”<<n<<endl;
cout << “The value of Pn = ”<< Pn<<endl;
cout << “The value of (*Pn) = ”<< (*Pn)<<endl;
cout << “The value of valueN = ”<< valueN;
getch( );
return 0;
}
EXPLANATION OF EXAMPLE:
In this example, the instructions at lines 10 and 14 make use of the dereference operator (*) and thus access the actual values of the original variable ‘n’ which is pointed out by the pointer ‘Pn’. In pointers, the ampersand operator (&) is the reference operator and can be read as “address of” and (*) is the dereference operator that can be read as “value pointed by”. These operators are complementary of each other and have opposite meanings. A variable referenced with & can be dereferenced with (*).

REFERENCE OPERATOR (&) OR ADDRESS OPERATOR
As pointers are the variables which hold the addresses of other variables, therefore, while assigning addresses to them, a programmer needs a special type of operator called reference or address operator that is denoted by ampersand (&) symbol. This provides the address of a memory location.


EXAMPLE:
Consider the following program:
// use of pointer in a program
#include <iostream.h>
#include<conio.h>
int main()
{
float x = 6.5;
float ‘fPointer;
fPointer= &x;
cout << “The address of x= ”<<&x << endl;
cout<< “The value of x= ”<<x<<endl;
cout << “The value of fPointer = ”<< fPointer;
getch();
return 0;
}


Q.6) What is meant by the term pointer initialization? Write a simple program to illustrate this concept.

Answer:
POINTER INITIALIZATION
DEFINITION:

“Assigning values to pointers at declaration time is called pointer initialization.”
EXPLANATION:
As we know that the values of pointers are the addresses of other variables, therefore, sometimes when we declare pointers we may want to explicitly specify to which variables they will point.
Consider the following segment of code to understand the concept of pointer initialization: float Temperature;
float *PTemperature = &Temperature;
Here, PTemperature is a pointer variable to a floating point variable. As this pointer is created with the statement ‘float * PTemperature’, immediately the address of a float variable ‘Temperature’ is assigned to it. The behavior of the above code is being equivalent to the following code.
float Temperature; float ‘PTemperature;
PTemperature = &Temperature;
It should be considered that at the moment of declaring a pointer, the asterisk (*) indicates only that it is a pointer variable and not the dereference operator.
EXAMPLE:
Consider the following program to explain the concept of pointer initialization.
#include “stdafx.h”
#include <iostream>
#include<conio.h>
using namespace std;
int main()
{
int  var = 20;   // actual variable declaration.
int  *ip;        // pointer variable

ip = &var;       // store address of var in pointer variable

cout << “Value of var variable: “;
cout << var << endl;

// print the address stored in ip pointer variable
cout << “Address stored in ip variable: “;
cout << ip << endl;

// access the value at the address available in pointer
cout << “Value of *ip variable: “;
cout << *ip << endl;

return 0;
}
Output:
The output  of the program is as follows:

fd
2nd Year Computer Science Notes Chapter 7 Pointers 2

Q.7) How the declaration of a pointer variable is different from the declaration of a variable.

Answer:
The declaration of the pointer is simple and is similar to the declaration of a regular variable with a minor difference of the use of asterisk * symbol between the data type and the variable name.


Reated Post:

  • 2nd-year computer science notes Chapter 1 Operating Systems
  • 2nd-year computer science notes Chapter 2 System Development Life Cycle
  • Computer Science Notes Chapter 5 Arrays and Strings
  • Chapter 3 Object-Oriented Programming using C++
  • 2nd year Computer science Notes Chapter 4 Control Structures

SendShareTweetPin4ShareShareShareShareSend
Previous Post

2nd Year Computer Science Notes Chapter 5 Arrays and Strings

Next Post

2nd year Computer Science Notes Chapter 8 Objects and Classes

RelatedPosts

KPK G12 Computer Science Notes Chapter 6 (Functions)
2nd year computer science notes

KPK G12 Computer Science Notes Chapter 6 (Functions)

39

The best Notes for exam preparation of 2021-22 kpk class...

Read more
Best 2nd Year Computer Science Notes of All Chapters

Best 2nd Year Computer Science Notes of All Chapters

220
Class 12 Computer Science Notes for KPK Chapter 9 File Handling

Class 12 Computer Science Notes for KPK Chapter 9 File Handling

34
Chapter 8 Objects and Classes

2nd year Computer Science Notes Chapter 8 Objects and Classes

81
Load More
Please login to join discussion
No Result
View All Result

Top Posts & Pages

  • Download file
  • KPK Text Book Board New 2021 PDF Download
  • Sindh textbook board Jamshoro books pdf download 2021
  • Download All Classes Notes in Pdf Class 9, Class 10, Class 11, & Class 12
  • Adamjee Islamiat Compulsory 9th Model Papers
  • Adamjee Sindhi Salees 10th Model Paper for New Pattern 2022
  • Sindh 9th Class Islamiat Notes PDF Download Urdu | Eng Medium
  • Biology 9th Adamjee Model Paper 2021

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 742 other subscribers

  • Trending
  • Comments
  • Latest
Sindh textbook board Jamshoro books pdf download

Sindh textbook board Jamshoro books pdf download 2021

KPK Text Book Board

KPK Text Book Board New 2021 PDF Download

9th Class Math Notes PDF Download Cha 1 to 9

Top 9th Class Math Notes PDF Download Cha 1 to 9

Class 12 English notes Lesson 1 to 20

Class 12 English notes Lesson 1 to 20 for KPK

Best Mothers Day Essay in English USA Gift Movie

Best Mothers Day Essay in English | USA | Gift | Movie

short essay on corruption in pakistan | essay on corruption with quotations | essay on corruption with outline | essay on corruption 500 words | essay on corruption in pakistan pdf | corruption essay pdf

500 Word Essay on Corruption In English

Essay on Co Education

Essay on Co Education – 500 Words

Visit the zoo Essay

Visit the zoo Essay

work and energy ch 6 physics g9 bise rawalpindi ex

Work and Energy Cha 6 Physic G9 Bise Rawalpindi

Gravitation Physics Cha 5 Bise Rawalpindi

Gravitation Physics G9 Cha 5 Bise Rawalpindi

Turning Effect of Forces Physics G9 Bise Rawalpindi Cha 4

Turning Effect of Forces Physics G9 Bise Rawalpindi Cha 4

Dynamics bise Rawalpindi 9th Physics Class Mcqs Notes Problems

Dynamics bise Rawalpindi 9th Physics Class Mcqs Notes Problems

Recent Posts

  • Work and Energy Cha 6 Physic G9 Bise Rawalpindi
  • Gravitation Physics G9 Cha 5 Bise Rawalpindi
  • Turning Effect of Forces Physics G9 Bise Rawalpindi Cha 4
  • Dynamics bise Rawalpindi 9th Physics Class Mcqs Notes Problems
  • Physics Cha 2 Kinematics Grade 9 Notes Rawalpindi Board
  • Home
  • Privacy Policy
  • Subscription
  • Contact us
  • Feedback
  • Disclaimer
  • Terms & Conditions
  • Cookies Policy
  • ABOUT US
  • Newsletter

© 2021 Perfect24u | All Rights Reserved

No Result
View All Result
  • Home
  • KPK NOTES
    • KPK TextBook Board
      • Grade 1
      • Grade 2
      • Grade 3
      • Grade 4
      • Grade 5
      • Grade 6
      • Grade 7
      • Grade 8
      • Grade 9
      • Grade 10 KPTBB BOOK
      • Grade 12 books for KPK
      • Grade 11 BOOK KPK Board
    • Class 7
      • Urdu
    • Class 9
      • Mathematics
      • English Class 9 Notes for KPK
      • 9th Urdu Notes
      • Biology 9th
      • Islamiat 9
      • Computer Science 9th
      • Pak Studies 9
      • Physics 9th
      • Chemistry 9th
    • Class 10
      • English 10th Notes
      • Biology 10 Class
      • CHEMISTRY 10 NOTES
      • class 10 Maths
      • Pak Study 10th
      • Physics 10
      • Urdu 10
    • Class 11 KPK Notes
      • 11 class biology notes KPK
      • 1st Year Mathematics Notes
      • chemistry class 11 notes
      • English FA Fsc Part 1 KPK
      • Islamiat Class 11 for kpk
      • Physics class 11 notes
    • 2nd Years
      • 2nd Year Chemistry Notes
      • Mathematics-XII
      • 2nd year computer science notes
      • 2nd Year Economics Notes
      • 2nd year English notes
      • 2nd year Pakistan Study Notes
      • 2nd Year Physics Notes
      • Bio Fsc Part 2
    • BISE Swat
      • Result
      • Model Papers
      • Chemistry Class 10 Notes
      • Class 11 Computer Science
      • Economics Notes Class 11
      • Statistics Class 11
      • Class 12 Statistics Notes
    • Syllabus
    • Mardan Board
      • 9th Notes
  • AIOU
    • B.ED books
    • B.S AIOU Books
    • Bachelor AIOU Books
    • CT AIOU Books
    • FA
  • BISE Lahore
    • Class X
      • English Class 10th Notes
    • Class IX
      • English Class 9th Notes
    • Class XI
      • English Class 11th Notes
    • Class XII
      • English Class 12th Notes
  • Sindh Board
    • Sindh Textbook Jamshoro
    • Class IX
      • Pak Studies Sindh 9
      • Computer Science 9 Sindh
      • Mathematic Sindh Class 9
      • Chemistry Notes
      • Biology 9
      • Physics
      • Sindh Board English 9th Notes
      • Islamiat Class 9 Sindh
    • Class X
      • Sindh Class 10 Physics
      • Sindh Class 10th English Notes
      • Islamiat Class 10 Sindh
    • Class XI
      • Islamiat
      • English notes class 11 Sindh board
    • Class XII
      • English Notes Sindh board 12th
  • CBSE
    • CBSE Class 9
    • CBSE Class 10
    • CBSE Class 11
    • CBSE Class 12
  • Rawalpindi Board
    • Class 9th
      • English 9th Notes
      • Biology G9
    • Class 10th
      • English 10th Notes
    • Class 11th
      • English 11th Notes
  • FBISE
    • 9 Class
      • Computer Science
      • Biology Notes
      • 9th FBISE Maths
      • Fbise 9 Notes Eng
    • 10 Class
      • English FBISE Notes
    • 11 Class
      • FBISE English 11th
    • 12 Class
      • Class 12 English Notes Fbise
    • FBISE Past Papers
      • 10 Class
      • 9th Past Papers
  • Articles
    • Essay
    • A-Z Universities in Pakistan
    • Admissions
    • All Country Independence Day
    • Countries Info
    • FILMORA
    • Education Qoutes
    • Happy Teacher Day
    • Insurance
    • Islamic
    • Muslim Boys names
    • Nelson’s Mandela
    • PHILONTHROPIC PRACTICES
    • Speeches
    • Story
  • DIT
  • DAE
  • MCQs
  • Technology
    • Marketing Think with Google
    • Science
  • Punjab board
    • Class 11 Notes PTBB
      • Computer Science PTBB Class 11
      • English 11 Notes Punjab
      • Chemsitry PTBB 11th
      • Math Notes PTBB 11th
      • Physics PTBB 11th
      • Urdu PTBB 11th
      • Biology 11th PTBB
    • Class 9
    • Punjab Class 10th
    • Punjab Board Class 10 Chemistry

© 2021 Perfect24u | All Rights Reserved

 

Loading Comments...
 

You must be logged in to post a comment.