This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Rabu, 18 Februari 2015

MEMASUKKAN DATA NILAI TERTINGGI TERENDAH DAN RATA-RATA

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>>>

INPUT DATA NILAI MAHASISWA

#include <iostream>
#include <conio.h>
#include <string>
#include <fstream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

main(int argc, char *argv[])

{
ofstream file_nilai;
int n,m;

cout<<"\tdata mahasiswa\n";
cout<<"------------------------------------\n";

cout<<"masukkan jumlah mahasiswa : ";
cin>>n;
int o[n];
float p[n],q[n],r[n],s[n];
string a[n];
cout<<endl;
m=0;
while (m<n){

cout<<"nama mahasiswa = ";
cin>>a[m];
cout<<"nim mahasiswa = ";
cin>>o[m];
cout<<"nilai harian = ";
cin>>p[m];
cout<<"nilai uts = ";
cin>>q[m];
cout<<"nilai uas = ";
cin>>r[m];
s[m]=(4*p[m]+4*q[m]+4*r[m])/300;
if(s[m]>=2.00)
{
cout<<"\nnilai akhir = "<<s[m];
cout<<"\nlulus";}
else
{
cout<<"\nnilai akhir = "<<s[m];
cout<<"\nbelum lulus";
}

cout<<endl;
cout<<endl;
m++;
}
file_nilai.open("data.txt");
if (file_nilai == NULL)
{
cout<<"File fail to open";
}
else
{for(m=0;m<n;m++){
file_nilai<<"Tampilkan Data hasilnya\n";
file_nilai<<"NAMA\t\tNIM\t\tHARIAN\tUTS\tUAS\tHASIL\n";
file_nilai<<a[m]<<"\t"<<o[m]<<"\t"<<p[m]<<"\t"<<q[m]<<"\t"<<r[m]<<"\t"<<s[m];
file_nilai.close();
}
getch();
}}


hasil>>>