Answer:
See explaination
Step-by-step explanation:
#include<iostream>
#include<stdio.h>
#include<conio.h>
#include<math.h>
using namespace std;
void main()
{
int RandomData[]={10,5,20,45,20,66,25,31,20,70}; //Random Data
int infant=0,young=0,middle=0,old=0,older=0; //To store count
int n,freq,count=0,high=0; //to store mode and other
double stdDev,mean,sum=0; //to store stdDev mean and sum
for(int i=0;i<(sizeof(RandomData)/sizeof(RandomData[0]));i++) //loop to count
{
if(RandomData[i]>0&&RandomData[i]<=18)
infant++;
else if(RandomData[i]>18&&RandomData[i]<=29)
young++;
else if(RandomData[i]>29&&RandomData[i]<=50)
middle++;
else if(RandomData[i]>50&&RandomData[i]<=69)
old++;
else if(RandomData[i]>69)
older++;
}
double first=0,sec=0; //to store result of stdDev formula first and second part
for(int i=0;i<(sizeof(RandomData)/sizeof(RandomData[0]));i++) //loop to calculate mean mode and stdDev
{
n=RandomData[i];
count=0;
for(int j=0;j<(sizeof(RandomData)/sizeof(RandomData[0]));j++)
{
if(n==RandomData[j])
count++;
}
if(high<count)
{
freq=RandomData[i];
high=count;
}
first+=(pow((RandomData[i]),2)/(sizeof(RandomData)/sizeof(RandomData[0])));
sec+=RandomData[i]/(sizeof(RandomData)/sizeof(RandomData[0]));
sum+=RandomData[i];
}
mean=sum/(sizeof(RandomData)/sizeof(RandomData[0]));
stdDev=sqrt(first-pow((sec),2));
/*------Printing Result-----*/
cout<<"\\Count:\\Infant: "<<infant<<"\\Young: "<<young<<"\\Middle: "<<middle;
cout<<"\\Old: "<<old<<"\\Older: "<<older;
cout<<"\\\\Mean: "<<mean<<"\\Mode: "<<freq<<"\\Standard Deviation: "<<stdDev;
/*-----------XXXX-------------*/
getch();
}