Selasa, 30 Juni 2015

C++ PROGRAM BILANGAN (terbesar, terkecil, rerata)

C++ PROGRAM BILANGAN (terbesar, terkecil, rerata)

#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;

int main(int argc, char *argv[]) {

int bil, total, trbesar, trkecil, rata, i, n;
total=0;

cout<<"==================================\n";
cout<<"| <<<<<< PROGRAM BILANGAN >>>>>> |\n";
cout<<"==================================\n\n";
cout<<"Masukkan banyaknya bilangan : "; cin>>n;
for(i=1; i<=n; i++){
cout<<"Masukkan bilangan : "; cin>>bil;
total=total+bil;
rata=total/n;
if(i==1){
trbesar=bil;
trkecil=bil;
}
else if(trkecil>bil){
trkecil=bil;
}
else if (trbesar<bil){

trbesar=bil;
}
else { }

}

cout<<"Jumlah Bilangan = "<<total<<endl;
cout<<"Rata-rata = "<<rata;
cout<<"\nBilangan Terbesar = "<<trbesar;
cout<<"\nBilangan Terkecil = "<<trkecil;

return 0;
}

HASIL COMPILE :





Related Posts:

  • C++ Program Rangkaian Listrik ( switch-case )C++ Program Rangkaian Listrik ( switch-case ) #include <iostream> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int main(int argc, char… Read More
  • C++ PROGRAM DERET FIBONACCI ITERATIF C++ PROGRAM DERET FIBONACCI ITERATIF #include <iostream> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; void fibonacci(int N){ int U1 = 0, U2 … Read More
  • C++ PROGRAM BILANGAN (terbesar, terkecil, rerata)C++ PROGRAM BILANGAN (terbesar, terkecil, rerata) #include <iostream> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int main(int argc, char … Read More
  • C++ PROGRAM PANGKAT (REKURSIF) C++  PROGRAM PANGKAT (REKURSIF) #include <iostream> #include <cstdlib> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int pangkat(… Read More
  • C++ Program Konversi Nilai UjianC++ Program Konversi Nilai Ujian #include <iostream> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int main(int argc, char *argv[]) { … Read More

0 komentar:

Posting Komentar