Program C++ Materi Tinggi Lingkaran (Array)
Kode :
//judul:Tinggi Lingkaran (Array)
// author : Ryota Irawan
//21 November 2022
#include <iostream>
using namespace std;
//Kamus
int tabumur[12],posisi[12];
float arrBB[12];
int max,tablength,sum,avg,i,m,w,x,y,z,a,b,cari,banyak;
bool ketemu;
//desk
int main(){
cout << "DATA UMUR" << endl;
tabumur[0] = 17;
tabumur[1] = 18;
tabumur[2] = 17;
tabumur[3] = 34;
tabumur[4] = 46;
tabumur[5] = 22;
tabumur[6] = 17;
tabumur[7] = 18;
tabumur[8] = 35;
tabumur[9] = 34;
tabumur[10] = 17;
tabumur[11] = 18;
a=0;
while (a<12){
cout << "Data Umur Ke - " << a << " = " <<tabumur[a] <<endl;
a=a+1;
}
cout << "DATA BERAT BADAN" << endl;
arrBB[0] = 34.9;
arrBB[1] = 56.6;
arrBB[2] = 38.5;
arrBB[3] = 76.3;
arrBB[4] = 69.4;
arrBB[5] = 72.5;
arrBB[6] = 101.6;
arrBB[7] = 85.1;
arrBB[8] = 88.4;
arrBB[9] = 73.7;
arrBB[10] = 66.6;
arrBB[11] = 84.9;
b=0;
while (b<12){
cout << "Data Berat Badan Ke - " << b << " = " <<arrBB[b] <<endl;
b=b+1;
}
//tampilkan tabumur & arrBB
tablength = 0;
x = 0;
while (x<12) {
cout << tabumur[x];
tablength=tablength+1;
x=x+1;
}
//jumlah isi tabel
sum=0;
y=0;
while(y<12){
cout << tabumur[y];
sum = sum + tabumur[y];
}
//rata2 isi tabel
avg = sum / tablength;
//pencarian nilai terbesar
max = tabumur[0];
z = 0;
while (z<12){
if (tabumur[z] > max){
max = tabumur[z];
z=z+1;
}
}
//pencarian sebuat data pada array
cout << "Masukkan Yang Dicari : ";cin>>cari;
banyak=0;
w=0
while (w<12){
if (tabumur[w] == cari){
ketemu = true
posisi[banyak]=banyak+1;
}
w=w+1;
}
if (ketemu == true){
cout << "Yg di cari " << cari << "Di temukan sebanyak" << banyak << endl;
cout << "Di lokasi indeks ke = " <<endl;
m=0;
while (m<banyak){
cout << posisi[i];
m=m+1;
}
}
else
}
Comments
Post a Comment