using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int x[100],n,max,min,i;
double a,b;
cout<<"Masukkan Banyaknya Data : ";cin>>n;
for (i=0;i<n;i++)
{cout<<"Masukan Nilai " <<i+1<<" : ";cin>>x[i];
}
max = x[0];
min = x[0];
for (i=0;i<n;i++)
{if (max < x[i])
{max = x[i];
}
if (min > x[i])
{ min = x[i];
}
}
cout<<"Nilai tertinggi = "<<max<<endl;
cout<<"Nilai terendah = "<<min<<endl;
a=0;
for (int i=0;i<n;i++)
{
a=a+x[i];
}
b=a/n;
cout<<"Rata-Rata : "<<a<<"/"<<n<<" = "<<b<<endl;
return 0;
}
HASIL>>>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int x[100],n,max,min,i;
double a,b;
cout<<"Masukkan Banyaknya Data : ";cin>>n;
for (i=0;i<n;i++)
{cout<<"Masukan Nilai " <<i+1<<" : ";cin>>x[i];
}
max = x[0];
min = x[0];
for (i=0;i<n;i++)
{if (max < x[i])
{max = x[i];
}
if (min > x[i])
{ min = x[i];
}
}
cout<<"Nilai tertinggi = "<<max<<endl;
cout<<"Nilai terendah = "<<min<<endl;
a=0;
for (int i=0;i<n;i++)
{
a=a+x[i];
}
b=a/n;
cout<<"Rata-Rata : "<<a<<"/"<<n<<" = "<<b<<endl;
return 0;
}
HASIL>>>