Logical Error in this program !! what i can do ?

#include <math.h>
#include <iostream>
using namespace std;


class statcalc
{private:
int dataset[10];

public:
void enter(int);
void constructor(int);
int getsum();
void print();
int getdata();
double getstandard();
double getmean();
int getmax();
int getmin();
};

void statcalc::constructor(int a=0)

{

for (int i=0;i<10;i++)
dataset[i]=a;

}
void statcalc::enter(int)

{int Ar[10];
cout<<"\n insert 10 Numbers: "<<endl;


for(int i=0;i<10;i++)
cin>>Ar[i];
dataset[10]=Ar[10];


}

void statcalc::print ()

{
for (int i=0;i<10;i++)
cout<<dataset[i]<<endl;

}

int statcalc::getdata ()

{return dataset[10];}
int statcalc::getsum ()
{
int sum=0;
for (int i=0;i<10;i++)
sum=sum+dataset[i];
return sum;
}

double statcalc::getmean()

{
double A,sum=0.0;

for (int i=0;i<10;i++)

sum=sum+dataset[i];
A=sum/10;

return A;

}

double statcalc::getstandard()
{

double w,A,q,sum=0.0;

for(int j=0;j<10;j++)
q+=(dataset[j]-A)*(dataset[j]-A);
w=sqrt(q/10);
return w;
}

int statcalc::getmax()
{

int max=0;

for(int i=0;i<10;i++)

if(dataset[i]>max)
max=dataset[i];

return max;

}

int statcalc::getmin()
{

int min=0;

for(int i=0;i<10;i++)

if(dataset[i]<min)
min=dataset[i];

return min;

}

void main()

{
statcalc pro;


int choice;
while(1)
{

cout<<"1. insert values of array."<<endl;
cout<<"2. print the content of array."<<endl;
cout<<"3. calculate the sum of all the items in the array."<<endl;
cout<<"4. calculate the average of all the items."<<endl;
cout<<"5. calculate the standard deviation of the items."<<endl;
cout<<"6. find the largest number of all the items that have be added to the dataset."<<endl;
cout<<"7. find the smallest number of all the items that have be added to the dataset."<<endl;
cout<<"8. Exit."<<endl;
cout<<endl;
cout<<endl;
cout<<endl;

cout<<"*******************************"<<endl;
cout<<"* *"<<endl;
cout<<"* Best Engeneers In The Wolrd *"<<endl;
cout<<"* <3 <3 *"<<endl;
cout<<"* Eng.Manar Jradat *"<<endl;
cout<<"* Eng.Sarah Alshaer *"<<endl;
cout<<"* <3 <3 *"<<endl;
cout<<"* *"<<endl;
cout<<"*******************************"<<endl;


cin>>choice;
switch (choice)

{


case 1:
int Ar[10];
pro.enter(Ar[10]);
break;


case 2:
pro.print();
cout<<pro.getdata()<<endl;

break;


case 3:
cout<<pro.getsum()<<endl;
break;


case 4:
cout<<pro.getmean()<<endl;
break;


case 5:
cout<<pro.getstandard()<<endl;
break;


case 6:
cout<<pro.getmax()<<endl;
break;


case 7:
cout<<pro.getmin()<<endl;
break;


case 8:
exit(0);
}
}

}
In C++, you main() function must return an int.

So line 115, change 'void main()' to 'int main()'

Hope this helps!
Topic archived. No new replies allowed.