In: Computer Science
Given the heights of 7 engineering students, H1, H2, H3, H4, H5, H6, H7. Create a pseudocode and flowchart to find the mean, median, mode, min, max, variance and standard deviation.
Pseudocode:-
Start Program
Set H1
Set H2
Set H3
Set H4
Set H5
Set H6
Set H7
Mean=Call FindMean(arguments: H1,H2,H3,H4,H5,H6,H7)
Median=H4
Mod=Call FindMod(arguments: H1,H2,H3,H4,H5,H6,H7)
Min=H1
Max=H7
Variance=Call FindVariance(arguments: H1,H2,H3,H4,H5,H6,H7)
Sd=Call FindSd(arguments: H1,H2,H3,H4,H5,H6,H7)
Call Display(arguments:Mean,Median,Mod,Min,Max,Variance,Sd)
End Program
Function FindMean(parameters: H1,H2,H3,H4,H5,H6,H7)
Set Mean to (H1+H2+H3+H4+H5+H6+H7)/7
Return(Mean)
End Function
Function FindMod(parameters: H1,H2,H3,H4,H5,H6,H7)
Set Mod=0
IF H2%H1>Mod
Mod=H2%H1
End IF
IF H3%H1>Mod
Mod=H3%H1
End IF
IF H4%H1>Mod
Mod=H4%H1
End IF
IF H5%H1>Mod
Mod=H5%H1
End IF
IF H6%H1>Mod
Mod=H6%H1
End IF
IF H7%H1>Mod
Mod=H7%H1
End IF
Return(Mod)
End Function
Function FindVariance(parameters: H1,H2,H3,H4,H5,H6,H7)
Mean=Call FindMean(arguments: H1,H2,H3,H4,H5,H6,H7)
Variance=((H1-Mean)^2+(H2-Mean)^2+(H3-Mean)^2+(H4-Mean)^2+(H5-Mean)^2+(H6-Mean)^2+(H7-Mean)^2)/7
Return(Variance)
End Function
Function FindSd(parameters: H1,H2,H3,H4,H5,H6,H7)
Sd=Call FindVariance(parameters:H1,H2,H3,H4,H5,H6,H7)
Return(sqrt(Sd))
End Function
Function Display(parameters:Mean,Median,Mod,Min,Max,Variance,Sd)
Print Mean
Print Median
Print Mod
Print Min
Print Max
Print Variance
Print Sd
End Function
-------------------------------------------------------------
Flowchart