SlideShare a Scribd company logo
1 of 1
Download to read offline
C++
Deviation from Average (Recursion)
Instructions
Step 1:
Write a recursive function called Deviation which passes array A and Dev as arrays with size n
and average, a floating point, as two other parameters. The function calculates the deviation (not
standard deviation), that is the difference between an element and average, for each element and
stores the deviation in array Dev[]. Both negative and positive differences are acceptable. Use
the average function below in (Step 2) to calculate average and pass it as input for the last
parameter. The function declaration (or signature) is:
void Deviation(int A[], double Dev[], int n, double average)
Step 2:
To help the function Deviation function use or pass the average value, write a function called
average which passes an array A, the size n, the size which is constant and the accumulating sum
which is already set to 0 to begin with. The function uses tail recursion approach to calculate the
average as floating-point and returns it. You must typecast the calculation into floating-point
when calculating. The function declaration is:
double average(int A[], int n, const int size, int sum = 0)
For this algorithm, you are required to implement it recursively.
Step 3:
In the main function, use two arrays where A stores integers and B stores floating-point numbers.
Using the functions, determine the deviations of each element from the mean, then display the
differences from array B.

More Related Content

Similar to C++ Deviation from Average (Recursion) Instructions Step 1- Write a.pdf

Layout planning
Layout planningLayout planning
Layout planning
8979473684
 
Java căn bản - Chapter3
Java căn bản - Chapter3Java căn bản - Chapter3
Java căn bản - Chapter3
Vince Vo
 
Cmc chapter 02
Cmc chapter 02Cmc chapter 02
Cmc chapter 02
Jane Hamze
 
C programming | Class 8 | III Term
C programming  | Class 8  | III TermC programming  | Class 8  | III Term
C programming | Class 8 | III Term
Andrew Raj
 
C++ Overview
C++ OverviewC++ Overview
C++ Overview
kelleyc3
 

Similar to C++ Deviation from Average (Recursion) Instructions Step 1- Write a.pdf (20)

Layout planning
Layout planningLayout planning
Layout planning
 
Quality Python Homework Help
Quality Python Homework HelpQuality Python Homework Help
Quality Python Homework Help
 
Mechanical Engineering Homework Help
Mechanical Engineering Homework HelpMechanical Engineering Homework Help
Mechanical Engineering Homework Help
 
Lesson 4.1 completing the problem solving process
Lesson 4.1 completing the problem solving processLesson 4.1 completing the problem solving process
Lesson 4.1 completing the problem solving process
 
Java căn bản - Chapter3
Java căn bản - Chapter3Java căn bản - Chapter3
Java căn bản - Chapter3
 
Ch03
Ch03Ch03
Ch03
 
International Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentInternational Journal of Engineering Research and Development
International Journal of Engineering Research and Development
 
Flowcharting
FlowchartingFlowcharting
Flowcharting
 
CE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdfCE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdf
 
working with python
working with pythonworking with python
working with python
 
Cmc chapter 02
Cmc chapter 02Cmc chapter 02
Cmc chapter 02
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2
 
Ann a Algorithms notes
Ann a Algorithms notesAnn a Algorithms notes
Ann a Algorithms notes
 
Java conceptual learning material
Java conceptual learning materialJava conceptual learning material
Java conceptual learning material
 
C programming | Class 8 | III Term
C programming  | Class 8  | III TermC programming  | Class 8  | III Term
C programming | Class 8 | III Term
 
1 Revision Tour
1 Revision Tour1 Revision Tour
1 Revision Tour
 
MuleSoft Nashik Virtual Meetup#3 - Deep Dive Into DataWeave and its Module
MuleSoft Nashik Virtual  Meetup#3 - Deep Dive Into DataWeave and its ModuleMuleSoft Nashik Virtual  Meetup#3 - Deep Dive Into DataWeave and its Module
MuleSoft Nashik Virtual Meetup#3 - Deep Dive Into DataWeave and its Module
 
C++ Overview
C++ OverviewC++ Overview
C++ Overview
 
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
 
F044033742
F044033742F044033742
F044033742
 

More from NIRMALJAI08

More from NIRMALJAI08 (20)

Calculate the five-number summary of the given data- Use the approxima.pdf
Calculate the five-number summary of the given data- Use the approxima.pdfCalculate the five-number summary of the given data- Use the approxima.pdf
Calculate the five-number summary of the given data- Use the approxima.pdf
 
Calculate the expected payments for- A- Office visit- new patient- det.pdf
Calculate the expected payments for- A- Office visit- new patient- det.pdfCalculate the expected payments for- A- Office visit- new patient- det.pdf
Calculate the expected payments for- A- Office visit- new patient- det.pdf
 
Calculate the Beta for Meta- Apple- Amazon- Netflix- and Alphabet for.pdf
Calculate the Beta for Meta- Apple- Amazon- Netflix- and Alphabet for.pdfCalculate the Beta for Meta- Apple- Amazon- Netflix- and Alphabet for.pdf
Calculate the Beta for Meta- Apple- Amazon- Netflix- and Alphabet for.pdf
 
Calculate P(Z0-1)- (Round to the hundredths)-.pdf
Calculate P(Z0-1)- (Round to the hundredths)-.pdfCalculate P(Z0-1)- (Round to the hundredths)-.pdf
Calculate P(Z0-1)- (Round to the hundredths)-.pdf
 
Calculate P(0-1Z0-1)- (Round to the hundredths)-.pdf
Calculate P(0-1Z0-1)- (Round to the hundredths)-.pdfCalculate P(0-1Z0-1)- (Round to the hundredths)-.pdf
Calculate P(0-1Z0-1)- (Round to the hundredths)-.pdf
 
Calclum is essential to tree growth- In 1990- the concentration of cal.pdf
Calclum is essential to tree growth- In 1990- the concentration of cal.pdfCalclum is essential to tree growth- In 1990- the concentration of cal.pdf
Calclum is essential to tree growth- In 1990- the concentration of cal.pdf
 
Calculate an estimated value of a share (P0) of the stock using the Co.pdf
Calculate an estimated value of a share (P0) of the stock using the Co.pdfCalculate an estimated value of a share (P0) of the stock using the Co.pdf
Calculate an estimated value of a share (P0) of the stock using the Co.pdf
 
Caitlin- Chris- and Molly are partners and share income and losses in.pdf
Caitlin- Chris- and Molly are partners and share income and losses in.pdfCaitlin- Chris- and Molly are partners and share income and losses in.pdf
Caitlin- Chris- and Molly are partners and share income and losses in.pdf
 
Caitlyn Communications reported the following figures from its adjuste.pdf
Caitlyn Communications reported the following figures from its adjuste.pdfCaitlyn Communications reported the following figures from its adjuste.pdf
Caitlyn Communications reported the following figures from its adjuste.pdf
 
C-CB+2A.pdf
C-CB+2A.pdfC-CB+2A.pdf
C-CB+2A.pdf
 
c- What is the probability that Z is between 1-51 and 1-81- The probab.pdf
c- What is the probability that Z is between 1-51 and 1-81- The probab.pdfc- What is the probability that Z is between 1-51 and 1-81- The probab.pdf
c- What is the probability that Z is between 1-51 and 1-81- The probab.pdf
 
C- Vitamin D is required for the absorption and deposition of calcium.pdf
C- Vitamin D is required for the absorption and deposition of calcium.pdfC- Vitamin D is required for the absorption and deposition of calcium.pdf
C- Vitamin D is required for the absorption and deposition of calcium.pdf
 
c- The login program will disallow logins of any students who enter th.pdf
c- The login program will disallow logins of any students who enter th.pdfc- The login program will disallow logins of any students who enter th.pdf
c- The login program will disallow logins of any students who enter th.pdf
 
C- Quantity Theory of Money In the country of Wiknam- assume that V is.pdf
C- Quantity Theory of Money In the country of Wiknam- assume that V is.pdfC- Quantity Theory of Money In the country of Wiknam- assume that V is.pdf
C- Quantity Theory of Money In the country of Wiknam- assume that V is.pdf
 
C- Picea mariana (black spruce) atsk This specimen was collected trom.pdf
C- Picea mariana (black spruce) atsk This specimen was collected trom.pdfC- Picea mariana (black spruce) atsk This specimen was collected trom.pdf
C- Picea mariana (black spruce) atsk This specimen was collected trom.pdf
 
c) Lefp and q be the pixels at coordinates (10-15) and (15-25) respect.pdf
c) Lefp and q be the pixels at coordinates (10-15) and (15-25) respect.pdfc) Lefp and q be the pixels at coordinates (10-15) and (15-25) respect.pdf
c) Lefp and q be the pixels at coordinates (10-15) and (15-25) respect.pdf
 
c- Identify a paraphyletic group in this phylogenetic tree and explain.pdf
c- Identify a paraphyletic group in this phylogenetic tree and explain.pdfc- Identify a paraphyletic group in this phylogenetic tree and explain.pdf
c- Identify a paraphyletic group in this phylogenetic tree and explain.pdf
 
C- elegans are one of the most common model organisms in biology- C-.pdf
C- elegans are one of the most common model organisms in biology-  C-.pdfC- elegans are one of the most common model organisms in biology-  C-.pdf
C- elegans are one of the most common model organisms in biology- C-.pdf
 
c++ The following questions are about the Memento design pattern- 6-1.pdf
c++ The following questions are about the Memento design pattern- 6-1.pdfc++ The following questions are about the Memento design pattern- 6-1.pdf
c++ The following questions are about the Memento design pattern- 6-1.pdf
 
C and D are events with probabilities P(C)-0-15-P(D)-0-3- and P(C UD)-.pdf
C and D are events with probabilities P(C)-0-15-P(D)-0-3- and P(C UD)-.pdfC and D are events with probabilities P(C)-0-15-P(D)-0-3- and P(C UD)-.pdf
C and D are events with probabilities P(C)-0-15-P(D)-0-3- and P(C UD)-.pdf
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Recently uploaded (20)

TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 

C++ Deviation from Average (Recursion) Instructions Step 1- Write a.pdf

  • 1. C++ Deviation from Average (Recursion) Instructions Step 1: Write a recursive function called Deviation which passes array A and Dev as arrays with size n and average, a floating point, as two other parameters. The function calculates the deviation (not standard deviation), that is the difference between an element and average, for each element and stores the deviation in array Dev[]. Both negative and positive differences are acceptable. Use the average function below in (Step 2) to calculate average and pass it as input for the last parameter. The function declaration (or signature) is: void Deviation(int A[], double Dev[], int n, double average) Step 2: To help the function Deviation function use or pass the average value, write a function called average which passes an array A, the size n, the size which is constant and the accumulating sum which is already set to 0 to begin with. The function uses tail recursion approach to calculate the average as floating-point and returns it. You must typecast the calculation into floating-point when calculating. The function declaration is: double average(int A[], int n, const int size, int sum = 0) For this algorithm, you are required to implement it recursively. Step 3: In the main function, use two arrays where A stores integers and B stores floating-point numbers. Using the functions, determine the deviations of each element from the mean, then display the differences from array B.