Contoh program c++ untuk fs stream alhorithma dengan array


NAMA : vasko edo minter gultom

NIM : 071402009

Modul 6 latihan 1

#include <iostream.h>

#include <fstream.h>

#include <stdlib.h>

int jlh_Array(int *array, int jlh_elemen)

{

int jlh=0;

srand(10000);

for(int i=0; i < jlh_elemen; i++)

jlh += (rand() % 100);

return jlh;

}

float jlh_Array(float *array, int jlh_elemen)

{

float jlh=0.0;

srand(10000);

for(int i=0; i < jlh_elemen; i++)

jlh += (rand() % 100);

return jlh;

}

int main()

{

int array_integer[5] = {rand()};

float array_float[5] = {rand()};

cout << “Jumlah array integer = ” << jlh_Array(array_integer, 5) << endl;

cout << “Jumlah array float = ” << jlh_Array(array_float, 5) << endl;

return 0;

}

modul 6 latihaN 2

#include <iostream.h>

#include <fstream.h>

#include <stdlib.h>

int jlh_Array(int *array, int jlh_elemen)

{

int jlh=0;

srand(10000);

for(int i=0; i < jlh_elemen; i++)

jlh += (rand() % 100);

return jlh;

}

float jlh_Array(float *array, int jlh_elemen)

{

float jlh=0.0;

srand(10000);

for(int i=0; i < jlh_elemen; i++)

jlh += (rand() % 100);

return jlh;

}

int main()

{

int array_integer[5] = {rand()};

float array_float[5] = {rand()};

cout << “Jumlah array integer = ” << jlh_Array(array_integer, 5) << endl;

cout << “Jumlah array float = ” << jlh_Array(array_float, 5) << endl;

return 0;

}

Tinggalkan Balasan

Please log in using one of these methods to post your comment:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s