SlideShare a Scribd company logo
1 of 2
For C++
1.Provide an example of a simple function and discuss what it does.
Solution
Functions are one of the important ways to decompose software into smaller,manageable
parts.Functions can have return values (for example,a function that computed might return that
value) or they can return nothing. If they return nothing, the return type is stated as void and the
function is sometimes called a procedure.
Example :
void f()
{
///////
}
float g(intx,int y)
{
float sum=x+y;
float avg=sum/2.0;
return avg;
}
int main()
{
f();
float z=g(2,3);
}
In the above example function f() takes no parameters and returns nothing(taht is,its return type
is void), and function g() takes two parameters of type int and returns a value of type float.

More Related Content

More from todd161

Find the Thevenin impedance at terminals a-b of the circuit on the rig.docx
Find the Thevenin impedance at terminals a-b of the circuit on the rig.docxFind the Thevenin impedance at terminals a-b of the circuit on the rig.docx
Find the Thevenin impedance at terminals a-b of the circuit on the rig.docxtodd161
 
Find the range and interquartile range and median of the following dat.docx
Find the range and interquartile range and median of the following dat.docxFind the range and interquartile range and median of the following dat.docx
Find the range and interquartile range and median of the following dat.docxtodd161
 
Shen yOu are told to plot log olD versus concentration- what variable.docx
Shen yOu are told to plot log olD versus concentration- what variable.docxShen yOu are told to plot log olD versus concentration- what variable.docx
Shen yOu are told to plot log olD versus concentration- what variable.docxtodd161
 
Should OSs be proprietary so that the manufacturers will be able to ma.docx
Should OSs be proprietary so that the manufacturers will be able to ma.docxShould OSs be proprietary so that the manufacturers will be able to ma.docx
Should OSs be proprietary so that the manufacturers will be able to ma.docxtodd161
 
Social Media in Healthcare What are the strengths of using social medi.docx
Social Media in Healthcare What are the strengths of using social medi.docxSocial Media in Healthcare What are the strengths of using social medi.docx
Social Media in Healthcare What are the strengths of using social medi.docxtodd161
 
Sirius is a binary star- consisting of Sirius A and Sirius B- Sirius B.docx
Sirius is a binary star- consisting of Sirius A and Sirius B- Sirius B.docxSirius is a binary star- consisting of Sirius A and Sirius B- Sirius B.docx
Sirius is a binary star- consisting of Sirius A and Sirius B- Sirius B.docxtodd161
 
Simplify- log 4 1Solution log 4 1 - log 1 - log 4 - 0.docx
Simplify- log 4 1Solution log  4  1 - log 1 - log 4  - 0.docxSimplify- log 4 1Solution log  4  1 - log 1 - log 4  - 0.docx
Simplify- log 4 1Solution log 4 1 - log 1 - log 4 - 0.docxtodd161
 
Several years ago a ring of foreign-based hackers broke into Town Bank.docx
Several years ago a ring of foreign-based hackers broke into Town Bank.docxSeveral years ago a ring of foreign-based hackers broke into Town Bank.docx
Several years ago a ring of foreign-based hackers broke into Town Bank.docxtodd161
 
Set up the chemical equation and balance for each (please write out )-.docx
Set up the chemical equation and balance for each (please write out )-.docxSet up the chemical equation and balance for each (please write out )-.docx
Set up the chemical equation and balance for each (please write out )-.docxtodd161
 
Soil Classification systems provide a common language to express conci.docx
Soil Classification systems provide a common language to express conci.docxSoil Classification systems provide a common language to express conci.docx
Soil Classification systems provide a common language to express conci.docxtodd161
 
Solution Approximate Acid- Base- or Approximate pH (2- 5- 7- 9- orNeut.docx
Solution Approximate Acid- Base- or Approximate pH (2- 5- 7- 9- orNeut.docxSolution Approximate Acid- Base- or Approximate pH (2- 5- 7- 9- orNeut.docx
Solution Approximate Acid- Base- or Approximate pH (2- 5- 7- 9- orNeut.docxtodd161
 
So I attempted drawing the new signal below- It is reflected- shifted.docx
So I attempted drawing the new signal below- It is reflected- shifted.docxSo I attempted drawing the new signal below- It is reflected- shifted.docx
So I attempted drawing the new signal below- It is reflected- shifted.docxtodd161
 
Simplify- log 4 1Solution log 4 1 - log 1 - log 4 - 0 (1).docx
Simplify- log 4 1Solution log  4  1 - log 1 - log 4  - 0 (1).docxSimplify- log 4 1Solution log  4  1 - log 1 - log 4  - 0 (1).docx
Simplify- log 4 1Solution log 4 1 - log 1 - log 4 - 0 (1).docxtodd161
 
Silver is immediately above gold on the periodic table and the two met.docx
Silver is immediately above gold on the periodic table and the two met.docxSilver is immediately above gold on the periodic table and the two met.docx
Silver is immediately above gold on the periodic table and the two met.docxtodd161
 
Shown below is an oxidation half-reaction in acidic solution- Which of.docx
Shown below is an oxidation half-reaction in acidic solution- Which of.docxShown below is an oxidation half-reaction in acidic solution- Which of.docx
Shown below is an oxidation half-reaction in acidic solution- Which of.docxtodd161
 
Show that the subset S - {0-2-4-6-8} of Z10 is a subring- Does S have.docx
Show that the subset S - {0-2-4-6-8} of Z10 is a subring- Does S have.docxShow that the subset S - {0-2-4-6-8} of Z10 is a subring- Does S have.docx
Show that the subset S - {0-2-4-6-8} of Z10 is a subring- Does S have.docxtodd161
 

More from todd161 (16)

Find the Thevenin impedance at terminals a-b of the circuit on the rig.docx
Find the Thevenin impedance at terminals a-b of the circuit on the rig.docxFind the Thevenin impedance at terminals a-b of the circuit on the rig.docx
Find the Thevenin impedance at terminals a-b of the circuit on the rig.docx
 
Find the range and interquartile range and median of the following dat.docx
Find the range and interquartile range and median of the following dat.docxFind the range and interquartile range and median of the following dat.docx
Find the range and interquartile range and median of the following dat.docx
 
Shen yOu are told to plot log olD versus concentration- what variable.docx
Shen yOu are told to plot log olD versus concentration- what variable.docxShen yOu are told to plot log olD versus concentration- what variable.docx
Shen yOu are told to plot log olD versus concentration- what variable.docx
 
Should OSs be proprietary so that the manufacturers will be able to ma.docx
Should OSs be proprietary so that the manufacturers will be able to ma.docxShould OSs be proprietary so that the manufacturers will be able to ma.docx
Should OSs be proprietary so that the manufacturers will be able to ma.docx
 
Social Media in Healthcare What are the strengths of using social medi.docx
Social Media in Healthcare What are the strengths of using social medi.docxSocial Media in Healthcare What are the strengths of using social medi.docx
Social Media in Healthcare What are the strengths of using social medi.docx
 
Sirius is a binary star- consisting of Sirius A and Sirius B- Sirius B.docx
Sirius is a binary star- consisting of Sirius A and Sirius B- Sirius B.docxSirius is a binary star- consisting of Sirius A and Sirius B- Sirius B.docx
Sirius is a binary star- consisting of Sirius A and Sirius B- Sirius B.docx
 
Simplify- log 4 1Solution log 4 1 - log 1 - log 4 - 0.docx
Simplify- log 4 1Solution log  4  1 - log 1 - log 4  - 0.docxSimplify- log 4 1Solution log  4  1 - log 1 - log 4  - 0.docx
Simplify- log 4 1Solution log 4 1 - log 1 - log 4 - 0.docx
 
Several years ago a ring of foreign-based hackers broke into Town Bank.docx
Several years ago a ring of foreign-based hackers broke into Town Bank.docxSeveral years ago a ring of foreign-based hackers broke into Town Bank.docx
Several years ago a ring of foreign-based hackers broke into Town Bank.docx
 
Set up the chemical equation and balance for each (please write out )-.docx
Set up the chemical equation and balance for each (please write out )-.docxSet up the chemical equation and balance for each (please write out )-.docx
Set up the chemical equation and balance for each (please write out )-.docx
 
Soil Classification systems provide a common language to express conci.docx
Soil Classification systems provide a common language to express conci.docxSoil Classification systems provide a common language to express conci.docx
Soil Classification systems provide a common language to express conci.docx
 
Solution Approximate Acid- Base- or Approximate pH (2- 5- 7- 9- orNeut.docx
Solution Approximate Acid- Base- or Approximate pH (2- 5- 7- 9- orNeut.docxSolution Approximate Acid- Base- or Approximate pH (2- 5- 7- 9- orNeut.docx
Solution Approximate Acid- Base- or Approximate pH (2- 5- 7- 9- orNeut.docx
 
So I attempted drawing the new signal below- It is reflected- shifted.docx
So I attempted drawing the new signal below- It is reflected- shifted.docxSo I attempted drawing the new signal below- It is reflected- shifted.docx
So I attempted drawing the new signal below- It is reflected- shifted.docx
 
Simplify- log 4 1Solution log 4 1 - log 1 - log 4 - 0 (1).docx
Simplify- log 4 1Solution log  4  1 - log 1 - log 4  - 0 (1).docxSimplify- log 4 1Solution log  4  1 - log 1 - log 4  - 0 (1).docx
Simplify- log 4 1Solution log 4 1 - log 1 - log 4 - 0 (1).docx
 
Silver is immediately above gold on the periodic table and the two met.docx
Silver is immediately above gold on the periodic table and the two met.docxSilver is immediately above gold on the periodic table and the two met.docx
Silver is immediately above gold on the periodic table and the two met.docx
 
Shown below is an oxidation half-reaction in acidic solution- Which of.docx
Shown below is an oxidation half-reaction in acidic solution- Which of.docxShown below is an oxidation half-reaction in acidic solution- Which of.docx
Shown below is an oxidation half-reaction in acidic solution- Which of.docx
 
Show that the subset S - {0-2-4-6-8} of Z10 is a subring- Does S have.docx
Show that the subset S - {0-2-4-6-8} of Z10 is a subring- Does S have.docxShow that the subset S - {0-2-4-6-8} of Z10 is a subring- Does S have.docx
Show that the subset S - {0-2-4-6-8} of Z10 is a subring- Does S have.docx
 

Recently uploaded

Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
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
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 

Recently uploaded (20)

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
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
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
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 

For C++ 1-Provide an example of a simple function and discuss what it.docx

  • 1. For C++ 1.Provide an example of a simple function and discuss what it does. Solution Functions are one of the important ways to decompose software into smaller,manageable parts.Functions can have return values (for example,a function that computed might return that value) or they can return nothing. If they return nothing, the return type is stated as void and the function is sometimes called a procedure. Example : void f() { /////// } float g(intx,int y) { float sum=x+y; float avg=sum/2.0; return avg; } int main() {
  • 2. f(); float z=g(2,3); } In the above example function f() takes no parameters and returns nothing(taht is,its return type is void), and function g() takes two parameters of type int and returns a value of type float.