SlideShare a Scribd company logo
1 of 2
C++
a) What is a null pointer?
b) Give an example of a function that returns a pointer.
Solution
a)
A pointer that is assigned NULL is called a null pointer.
The NULL pointer is a constant with a value of zero defined in several standard libraries,
including iostream.
It is always a good practice to assign the pointer NULL to a pointer variable in case you do not
have exact address to be assigned.
Example : int *ptr = NULL; // integer pointer pointing to NULL
b)
// function that returns a pointer to integer variable
int *add(int a, int b){
int c = a+ b;
int *iptr = &c; // pointer that stores address of c
return iptr;
}
C++ a) What is a null pointer- b) Give an example of a function that r.docx

More Related Content

More from curtisp2

Brent gets a loan from San Fransisco Bank- Brent signs a standard form.docx
Brent gets a loan from San Fransisco Bank- Brent signs a standard form.docxBrent gets a loan from San Fransisco Bank- Brent signs a standard form.docx
Brent gets a loan from San Fransisco Bank- Brent signs a standard form.docxcurtisp2
 
Calculate the cell potential (Ecell for the following lead concentrati.docx
Calculate the cell potential (Ecell for the following lead concentrati.docxCalculate the cell potential (Ecell for the following lead concentrati.docx
Calculate the cell potential (Ecell for the following lead concentrati.docxcurtisp2
 
Calculate -OH-- concentration of solutions with the following pH value.docx
Calculate -OH-- concentration of solutions with the following pH value.docxCalculate -OH-- concentration of solutions with the following pH value.docx
Calculate -OH-- concentration of solutions with the following pH value.docxcurtisp2
 
Cafeteria plan has following advantages- 1-Employees more likely to ap.docx
Cafeteria plan has following advantages- 1-Employees more likely to ap.docxCafeteria plan has following advantages- 1-Employees more likely to ap.docx
Cafeteria plan has following advantages- 1-Employees more likely to ap.docxcurtisp2
 
By treating a student as aSolutionInvitation of appliction for admissi.docx
By treating a student as aSolutionInvitation of appliction for admissi.docxBy treating a student as aSolutionInvitation of appliction for admissi.docx
By treating a student as aSolutionInvitation of appliction for admissi.docxcurtisp2
 
By how much will the pH change if 0-025 mol of HCl is added to 1-00 L.docx
By how much will the pH change if 0-025 mol of HCl is added to 1-00 L.docxBy how much will the pH change if 0-025 mol of HCl is added to 1-00 L.docx
By how much will the pH change if 0-025 mol of HCl is added to 1-00 L.docxcurtisp2
 
Build a trie of the following terms using- a- A pointer representation.docx
Build a trie of the following terms using- a- A pointer representation.docxBuild a trie of the following terms using- a- A pointer representation.docx
Build a trie of the following terms using- a- A pointer representation.docxcurtisp2
 

More from curtisp2 (7)

Brent gets a loan from San Fransisco Bank- Brent signs a standard form.docx
Brent gets a loan from San Fransisco Bank- Brent signs a standard form.docxBrent gets a loan from San Fransisco Bank- Brent signs a standard form.docx
Brent gets a loan from San Fransisco Bank- Brent signs a standard form.docx
 
Calculate the cell potential (Ecell for the following lead concentrati.docx
Calculate the cell potential (Ecell for the following lead concentrati.docxCalculate the cell potential (Ecell for the following lead concentrati.docx
Calculate the cell potential (Ecell for the following lead concentrati.docx
 
Calculate -OH-- concentration of solutions with the following pH value.docx
Calculate -OH-- concentration of solutions with the following pH value.docxCalculate -OH-- concentration of solutions with the following pH value.docx
Calculate -OH-- concentration of solutions with the following pH value.docx
 
Cafeteria plan has following advantages- 1-Employees more likely to ap.docx
Cafeteria plan has following advantages- 1-Employees more likely to ap.docxCafeteria plan has following advantages- 1-Employees more likely to ap.docx
Cafeteria plan has following advantages- 1-Employees more likely to ap.docx
 
By treating a student as aSolutionInvitation of appliction for admissi.docx
By treating a student as aSolutionInvitation of appliction for admissi.docxBy treating a student as aSolutionInvitation of appliction for admissi.docx
By treating a student as aSolutionInvitation of appliction for admissi.docx
 
By how much will the pH change if 0-025 mol of HCl is added to 1-00 L.docx
By how much will the pH change if 0-025 mol of HCl is added to 1-00 L.docxBy how much will the pH change if 0-025 mol of HCl is added to 1-00 L.docx
By how much will the pH change if 0-025 mol of HCl is added to 1-00 L.docx
 
Build a trie of the following terms using- a- A pointer representation.docx
Build a trie of the following terms using- a- A pointer representation.docxBuild a trie of the following terms using- a- A pointer representation.docx
Build a trie of the following terms using- a- A pointer representation.docx
 

Recently uploaded

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 

Recently uploaded (20)

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 

C++ a) What is a null pointer- b) Give an example of a function that r.docx

  • 1. C++ a) What is a null pointer? b) Give an example of a function that returns a pointer. Solution a) A pointer that is assigned NULL is called a null pointer. The NULL pointer is a constant with a value of zero defined in several standard libraries, including iostream. It is always a good practice to assign the pointer NULL to a pointer variable in case you do not have exact address to be assigned. Example : int *ptr = NULL; // integer pointer pointing to NULL b) // function that returns a pointer to integer variable int *add(int a, int b){ int c = a+ b; int *iptr = &c; // pointer that stores address of c return iptr; }