Jumat, 08 Juli 2011

Program Menentukan Max, Min dan Jumlah Cpp

  Agus Nur Ikhsan       Jumat, 08 Juli 2011
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <conio.h>
#include <math.h>

using namespace std;

void input(int x[],int n)
{
for (int i=1;i<=n;i++)
{cout<<"Masukan Nilai "<<i<<" : ";cin>>x[i];}
}

void tinggi(int x[],int n)
{
int max,min;
max = x[1];
min = x[1];
for (int i=2;i<=n;i++)
{
if (max < x[i])
max = x[i];
if (min > x[i])
min = x[i];
}
cout<<"\nNilai tertinggi  = "<<max<<"\n";
cout<<"Nilai terendah   = "<<min<<"\n";
}

/*double rata(int x[],int n)
{
double a,b;
a = 0;
for (int i=1;i<=n;i++)
{
a = a + x[i];
}
b = a/n;
cout<<"Rata-Rata : "<<a<<"/"<<n<<" = "<<b;
}

double deviasi(int x[],int n){
       double c,d;
       for(int i=1;i<=n;i++){
       cout<<x[i];
       c=c+x[i];
               }
       d=a/n;
       
       }*/

int main(int argc, char *argv[])
{
int p[50],N;
cout<<"Banyaknya Data : ";cin>>N;
cout<<endl;
input(p,N);
tinggi(p,N);
//rata (p,N);
getch();
cout<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}
logoblog

Thanks for reading Program Menentukan Max, Min dan Jumlah Cpp

Previous
« Prev Post

Tidak ada komentar:

Posting Komentar