Program C++ Materi (Data Umur - Array)

 Kode :

//judul = Data Umur



#include <iostream>

using namespace std;





//kamus

//int

int Tabumur[12];

int sumanto;

int x,y;


//float

float TabBB[12];

float sumanti;





//diskripsi

int main (){


    // mengisi array

    cout <<"Mencari 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;


    TabBB[0] = 34.9;

    TabBB[1] = 40.1;

    TabBB[2] = 35.2;

    TabBB[3] = 47.1;

    TabBB[4] = 46.3;

    TabBB[5] = 11.2;

    TabBB[6] = 16.1;

    TabBB[7] = 33.7;

    TabBB[8] = 39.2;

    TabBB[9] = 34.9;

    TabBB[10] = 19.1;

    TabBB[11] = 22.5;


x=1;

y=y+1;

do{

    cout << Tabumur [x] << " ";

    x=x+1;

}while(x<12);


cout <<endl;


y=0;

do{

    cout << TabBB [y] << " " ;

    y=y+1;

}while(y<12);


cout <<endl;

cout <<endl;

cout <<endl;


//jumlah isi tabel

sumanto = 0;

x = 1;

do{

    cout << Tabumur [x] << " ";

    sumanto = sumanto + Tabumur[x];

    x=x+1;

}while(x<12);


cout << "= " << sumanto;


cout <<endl;


sumanti = 0;

y = 1;

do{

    cout << TabBB [y] << " ";

    sumanti = sumanti + TabBB[y];

    y=y+1;

}while(y<12);


cout << "= " << sumanti;



}


Comments