SHARE
TWEET

Bilangan Terbesar/Terkecil Dengan Array

MSadam Nov 13th, 2019 214 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. main()
  5. {
  6.     float a[100];
  7.     int i,min,max;
  8.    
  9.     /*cout<<"Masukan Jumlah Input Bilangan : ";
  10.     cin>>k;
  11.     cout<<endl;*/
  12.     cout<<"======[ Input Bilangan ]======"<<endl<<endl;
  13.     for(i=0; i<10; i++){
  14.         cout<<"Masukan Bilangan Ke- "<<i+1<<" : ";
  15.         cin>>a[i];
  16.     }
  17.         max = a[0];
  18.         for(i=1; i<10; i++){
  19.             if(min>a[i])
  20.                 min = a[i];
  21.             if(max<a[i])
  22.                 max = a[i];
  23.         }
  24.     cout<<endl<<"=================================="<<endl;
  25.     cout<<"Bilangan Terbesar Adalah "<<max<<endl;
  26.     cout<<"Bilangan Terkecil Adalah "<<min<<endl;
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top