Posted by : deari q
Senin, 31 Maret 2014
Program C++
#include <cstdlib>
#include <iostream>
using namespace std;
int main (int argc, char *argv[])
{
int N, nilai, i;
int maks=1;
int min=1;
cout << " Mencari nilai maksimum
dan minimum" << endl;
cout << " Masukkan nilai N :
";
cin>>N;
cout<<endl;
for
(i=1; i<=N; i++){
cin>>nilai;
if ( i == 1 ) {
min
= nilai;
maks
= nilai;
}
else if ( min > nilai ) {
min
= nilai;
}
else if ( maks < nilai) {
maks = nilai;
}
}
cout << "Nilai minimal : "
<<min<<endl;
cout << "Nilai maksimum : " <<maks<<endl;
system("pause");
return
0;