#include <iostream>
#include <math.h>
usingnamespace std;
int main()
{
int maxsize=9999999;
cout<<"*******************************PROG STATISTICS*******************************\n";
cout<<">>>Please enter #'s between 1 & "<<maxsize<<" for everything-DECIMALS WILL BE IGNORED"<<endl;
cout<<">>>Enter the amount of numbers you want to analyze: ";
//get size array
int arraysize, countersec=0, meancount=0, Modecount=0, var=0, mean=0;
cin>>arraysize;
//
cout<<">>>Enter all numbers you want analysis on!"<<endl;
//input numbers for list
int numlist[arraysize];
int seclist[arraysize];
for (int i=0; i<arraysize; i++)
{
cout<<"Number "<<i+1<<": ";
cin>>numlist[i];
if ((numlist[i]>maxsize) or (numlist[i]<1))
{
cout<<"Major error, you went too large idiot-Re Enter your number...\n";
i--;
}
seclist[i]=0;
}
for (int b=0; b<maxsize; b++)
{
for (int i=0; i<arraysize; i++)
{
if (numlist[i]==b)
{
seclist[countersec]=numlist[i];
countersec++;
}
}
}
cout<<"*******************************"<<endl<<endl<<"Ordered List=";
for (int i=0; i<arraysize; i++)
{
meancount=meancount+seclist[i];
cout<<seclist[i]<<"|";
}
mean=(meancount/arraysize);
cout<<"\nMean="<<(mean);
if ((arraysize % 2)==0)
{
Modecount=(seclist[(arraysize/2)-1]+seclist[(arraysize/2)])/2;
}
if ((arraysize % 2)!=0)
{
Modecount=seclist[(arraysize/2)]+.5;
}
cout<<"\nMode="<<Modecount<<endl;
for (int i=0; i<arraysize; i++)
{
var=var+((seclist[i]-mean)*((seclist[i]-mean)));
}
var=(var/arraysize);
cout<<"Variance="<<var<<endl;
cout<<"Standard Deviation="<<sqrt(var)<<endl<<endl;
cout<<"*******************************";
}
Thank you. Just corrected that. Error now says too large/small. The other problem i seem to have is that if the user enters a number way too large, it will crash the program. Why is this?
Is this because the data can't properly fit in an "int" structure?