SlideShare a Scribd company logo
Team Emertxe
Advanced Pointers,
Arrays and Functions
Assignment 2
Assignment 2
Assignment 2
WAP to perform variance calculation with dynamic arrays.
Assignment 2
WAP to perform variance calculation with dynamic arrays.
Input: Read array size ‘N’ and read array elements of size ‘N’
Assignment 2
WAP to perform variance calculation with dynamic arrays.
Input: Read array size ‘N’ and read array elements of size ‘N’
Output: Print the variance
Assignment 2
What is variance?
Assignment 2
What is variance?
Variance measures how far a set of numbers is spread out.
Assignment 2
Example :-
Assignment 2
Example :-
Step 1 : Read size ‘N’
Assignment 2
Example :-
Step 1 : Read size ‘N’
N = 7
Assignment 2
Example :-
Step 1 : Read size ‘N’
N = 7
Step 2 : Dynamically allocate the memory for array ‘arr’ of size ‘N’
Assignment 2
Example :-
Step 1 : Read size ‘N’
N = 7
Step 2 : Dynamically allocate the memory for array ‘arr’ of size ‘N’
Step 3 : Read ‘N’ number of array elements
Assignment 2
Example :-
Step 1 : Read size ‘N’
N = 7
Step 2 : Dynamically allocate the memory for array ‘arr’ of size ‘N’
Step 3 : Read ‘N’ number of array elements
4 2 7 1 5 3 6
arr
Assignment 2
Example :-
Step 4 : Calculate Mean
Assignment 2
Example :-
Step 4 : Calculate Mean
4 2 7 1 5 3 6
arr
Assignment 2
Example :-
Step 4 : Calculate Mean
Mean = sum of all elements in ‘arr’ / size
4 2 7 1 5 3 6
arr
Assignment 2
Example :-
Step 4 : Calculate Mean
Mean = sum of all elements in ‘arr’ / size
Mean = 28 / 7
4 2 7 1 5 3 6
arr
Assignment 2
Example :-
Step 4 : Calculate Mean
Mean = sum of all elements in ‘arr’ / size
Mean = 28 / 7
Mean = 4
4 2 7 1 5 3 6
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
4 2 7 1 5 3 6
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] - Mean
4 2 7 1 5 3 6
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] – Mean
4 2 7 1 5 3 6
0 1 2 3 4 5 6
i
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] – Mean
D[0] = 4 – 4 = 0
4 2 7 1 5 3 6
0 1 2 3 4 5 6
i
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] – Mean
D[0] = 4 – 4 = 0
4 2 7 1 5 3 6
0 1 2 3 4 5 6
i
0
D
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] – Mean
4 2 7 1 5 3 6
0 1 2 3 4 5 6
i
0
D
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] – Mean
D[1] = 2 – 4 = -2
4 2 7 1 5 3 6
0 1 2 3 4 5 6
i
0
D
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] – Mean
D[1] = 2 – 4 = -2
4 2 7 1 5 3 6
0 1 2 3 4 5 6
i
0 -2
D
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] – Mean
4 2 7 1 5 3 6
0 1 2 3 4 5 6
i
0 -2
D
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] – Mean
D[2] = 7 – 4 = 3
4 2 7 1 5 3 6
0 1 2 3 4 5 6
i
0 -2
D
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] – Mean
D[2] = 7 – 4 = 3
4 2 7 1 5 3 6
0 1 2 3 4 5 6
i
0 -2 3
D
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] – Mean
4 2 7 1 5 3 6
0 1 2 3 4 5 6
i
0 -2 3
D
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] – Mean
D[3] = 1 – 4 = -3
4 2 7 1 5 3 6
0 1 2 3 4 5 6
i
0 -2 3
D
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] – Mean
D[3] = 1 – 4 = -3
4 2 7 1 5 3 6
0 1 2 3 4 5 6
i
0 -2 3 -3
D
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] – Mean
4 2 7 1 5 3 6
0 1 2 3 4 5 6
i
0 -2 3 -3
D
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] – Mean
D[4] = 5 – 4 = 1
4 2 7 1 5 3 6
0 1 2 3 4 5 6
i
0 -2 3 -3
D
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] – Mean
D[4] = 5 – 4 = 1
4 2 7 1 5 3 6
0 1 2 3 4 5 6
i
0 -2 3 -3 1
D
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] – Mean
4 2 7 1 5 3 6
0 1 2 3 4 5 6
i
0 -2 3 -3 1
D
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] – Mean
D[5] = 3 – 4 = -1
4 2 7 1 5 3 6
0 1 2 3 4 5 6
i
0 -2 3 -3 1
D
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] – Mean
D[5] = 3 – 4 = -1
4 2 7 1 5 3 6
0 1 2 3 4 5 6
i
0 -2 3 -3 1 -1
D
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] – Mean
4 2 7 1 5 3 6
0 1 2 3 4 5 6
i
0 -2 3 -3 1 -1
D
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] – Mean
D[6] = 6 – 4 = 2
4 2 7 1 5 3 6
0 1 2 3 4 5 6
i
0 -2 3 -3 1 -1
D
arr
Assignment 2
Example :-
Step 5 : Calculate Deviation (D)
D[i] = arr[i] – Mean
D[6] = 6 – 4 = 2
4 2 7 1 5 3 6
0 1 2 3 4 5 6
i
0 -2 3 -3 1 -1 2
D
arr
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
D
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
D
i
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
D_sqr[0] = (0) * (0)
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
D
i
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
D_sqr[0] = (0) * (0)
D_sqr[0] = 0
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
D
i
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
D_sqr[0] = (0) * (0)
D_sqr[0] = 0
0 -2 3 -3 1 -1 2
D_sqr
0 1 2 3 4 5 6
0
D
i
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
0
D
i
D_sqr
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
D_sqr[1] = (-2) * (-2)
D_sqr[1] = 4
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
0
D
i
D_sqr
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
D_sqr[1] = (-2) * (-2)
D_sqr[1] = 4
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
0 4
D
i
D_sqr
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
0 4
D
i
D_sqr
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
D_sqr[2] = (3) * (3)
D_sqr[2] = 9
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
0 4
D
i
D_sqr
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
D_sqr[2] = (3) * (3)
D_sqr[2] = 9
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
0 4 9
D
i
D_sqr
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
0 4 9
D
i
D_sqr
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
D_sqr[3] = (-3) * (-3)
D_sqr[3] = 9
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
0 4 9
D
i
D_sqr
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
D_sqr[3] = (-3) * (-3)
D_sqr[3] = 9
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
0 4 9 9
D
i
D_sqr
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
0 4 9 9
D
i
D_sqr
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
D_sqr[4] = (1) * (1)
D_sqr[4] = 1
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
0 4 9 9
D
i
D_sqr
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
D_sqr[4] = (1) * (1)
D_sqr[4] = 1
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
0 4 9 9 1
D
i
D_sqr
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
0 4 9 9 1
D
i
D_sqr
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
D_sqr[5] = (-1) * (-1)
D_sqr[5] = 1
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
0 4 9 9 1
D
i
D_sqr
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
D_sqr[5] = (-1) * (-1)
D_sqr[5] = 1
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
0 4 9 9 1 1
D
i
D_sqr
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
0 4 9 9 1 1
D
i
D_sqr
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
D_sqr[6] = (2) * (2)
D_sqr[6] = 4
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
0 4 9 9 1 1
D
i
D_sqr
Assignment 2
Example :-
Step 6 : Calculate square of Deviation and store in ‘D_sqr’ array
D_sqr[6] = (2) * (2)
D_sqr[6] = 4
0 -2 3 -3 1 -1 2
0 1 2 3 4 5 6
0 4 9 9 1 1 4
D
i
D_sqr
Assignment 2
Example :-
Step 7 : Calculate Mean for square of the Deviation ‘D_sqr’ array
Assignment 2
Example :-
Step 7 : Calculate Mean for square of the Deviation ‘D_sqr’ array
0 4 9 9 1 1 4
0 1 2 3 4 5 6
D_sqr
Assignment 2
Example :-
Step 7 : Calculate Mean for square of the Deviation ‘D_sqr’ array
Variance = sum of all elements in ‘D_sqr’ / size
0 4 9 9 1 1 4
0 1 2 3 4 5 6
D_sqr
Assignment 2
Example :-
Step 7 : Calculate Mean for square of the Deviation ‘D_sqr’ array
Variance = sum of all elements in ‘D_sqr’ / size
Variance = 28 / 7
0 4 9 9 1 1 4
0 1 2 3 4 5 6
D_sqr
Assignment 2
Example :-
Step 7 : Calculate Mean for square of the Deviation ‘D_sqr’ array
Variance = sum of all elements in ‘D_sqr’ / size
Variance = 28 / 7
Variance = 4.000000
0 4 9 9 1 1 4
0 1 2 3 4 5 6
D_sqr
Assignment 2
Example :-
Step 8 : Print the variance
Assignment 2
Example :-
Step 8 : Print the variance
Variance = 4.000000
Sample execution:-
Assignment 2
Sample execution:-
Assignment 2
Assignment 2
Pre-requisites:-
Assignment 2
Pre-requisites:-
Functions
Assignment 2
Pre-requisites:-
Functions
Pointers
Assignment 2
Pre-requisites:-
Functions
Pointers
Dynamic memory allocation
Assignment 2
Pre-requisites:-
Functions
Pointers
Dynamic memory allocation
Objective:-
Assignment 2
Pre-requisites:-
Functions
Pointers
Dynamic memory allocation
Objective:-
To understand the concept of functions , pointers and dynamic
memory allocation.
Team Emertxe
Thank you

More Related Content

DOCX
#include PA3Header.h#include stdafx.h Function r.docx
PPTX
Chapter-6-Variance.pptx
PDF
C++ Deviation from Average (Recursion) Instructions Step 1- Write a.pdf
PPTX
Chapter-6-Variance Purposive Communication.pptx
PDF
Question 1 has already been posted to Chegg and I am waiting for the.pdf
PDF
Program 1 (Practicing an example of function using call by referenc.pdf
PPT
IB-TBWordJumbleGame-energizer IB-TBWordJumbleGame-energizer
PDF
matlab functions
#include PA3Header.h#include stdafx.h Function r.docx
Chapter-6-Variance.pptx
C++ Deviation from Average (Recursion) Instructions Step 1- Write a.pdf
Chapter-6-Variance Purposive Communication.pptx
Question 1 has already been posted to Chegg and I am waiting for the.pdf
Program 1 (Practicing an example of function using call by referenc.pdf
IB-TBWordJumbleGame-energizer IB-TBWordJumbleGame-energizer
matlab functions

Similar to 02_variance.pdf (20)

PDF
Learning R
PPT
Statistics
DOCX
Statistics notes ,it includes mean to index numbers
PDF
Reaction StatisticsBackgroundWhen collecting experimental data f.pdf
PDF
Write a C++ program to get input of a data set of 14 double valu.pdf
PPTX
Python Statistics.pptx
PPTX
3.2 measures of variation
PDF
Matlab tutorial 2
PPTX
Calculation of arithmetic mean
PPT
Standard deviation quartile deviation
PDF
profiency Math.pdf
PDF
Solucionario_de_Chapra_y_Canale_Quinta_E.pdf
PDF
please help implement the following in C. below are instructions and.pdf
PDF
Background Sometimes the standard C libraries (stdio.h, stdlib.h, e.pdf
PPTX
3.2 measures of variation
ODT
Chassis Development And telemetry Calculations.
PPTX
Introduction to Matlab and application.pptx
PPT
Measure of Dispersion - Grade 8 Statistics.ppt
PDF
PPS SSSSHHEHESHSHEHHEHAKAKHEHE12131415.pdf
Learning R
Statistics
Statistics notes ,it includes mean to index numbers
Reaction StatisticsBackgroundWhen collecting experimental data f.pdf
Write a C++ program to get input of a data set of 14 double valu.pdf
Python Statistics.pptx
3.2 measures of variation
Matlab tutorial 2
Calculation of arithmetic mean
Standard deviation quartile deviation
profiency Math.pdf
Solucionario_de_Chapra_y_Canale_Quinta_E.pdf
please help implement the following in C. below are instructions and.pdf
Background Sometimes the standard C libraries (stdio.h, stdlib.h, e.pdf
3.2 measures of variation
Chassis Development And telemetry Calculations.
Introduction to Matlab and application.pptx
Measure of Dispersion - Grade 8 Statistics.ppt
PPS SSSSHHEHESHSHEHHEHAKAKHEHE12131415.pdf
Ad

More from Emertxe Information Technologies Pvt Ltd (20)

Ad

Recently uploaded (20)

PPTX
How to Manage Loyalty Points in Odoo 18 Sales
PDF
Insiders guide to clinical Medicine.pdf
PDF
The Final Stretch: How to Release a Game and Not Die in the Process.
PPTX
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
LDMMIA Reiki Yoga Workshop 15 MidTerm Review
PDF
High Ground Student Revision Booklet Preview
PPTX
Onica Farming 24rsclub profitable farm business
PPTX
Cardiovascular Pharmacology for pharmacy students.pptx
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
PDF
From loneliness to social connection charting
PPTX
Introduction and Scope of Bichemistry.pptx
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Cell Biology Basics: Cell Theory, Structure, Types, and Organelles | BS Level...
PDF
Module 3: Health Systems Tutorial Slides S2 2025
PDF
Landforms and landscapes data surprise preview
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
LDMMIA Reiki Yoga S2 L3 Vod Sample Preview
PPTX
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
How to Manage Loyalty Points in Odoo 18 Sales
Insiders guide to clinical Medicine.pdf
The Final Stretch: How to Release a Game and Not Die in the Process.
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
102 student loan defaulters named and shamed – Is someone you know on the list?
LDMMIA Reiki Yoga Workshop 15 MidTerm Review
High Ground Student Revision Booklet Preview
Onica Farming 24rsclub profitable farm business
Cardiovascular Pharmacology for pharmacy students.pptx
NOI Hackathon - Summer Edition - GreenThumber.pptx
From loneliness to social connection charting
Introduction and Scope of Bichemistry.pptx
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Cell Biology Basics: Cell Theory, Structure, Types, and Organelles | BS Level...
Module 3: Health Systems Tutorial Slides S2 2025
Landforms and landscapes data surprise preview
Abdominal Access Techniques with Prof. Dr. R K Mishra
LDMMIA Reiki Yoga S2 L3 Vod Sample Preview
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf

02_variance.pdf