met mencoba yccc, , , , ^_^
#include <iostream.h>
#include <conio.h>
void ambil (double*&, int&);
void print (double*, int);
void sum (double*, double*, int);
int main(){
double* b;
double* a;
int n;
ambil (a,n);
cout << endl;
print (a,n);
cout << endl;
ambil (b,n);
cout << endl;
print (b,n);
cout << endl;
sum (a,b,n);
getch();
return 0;
}
void ambil (double*& a, int& m){
cout << "masukkan jumlah bilangan (1 sampai 10) : ";
cin >> m;
a = new double[m];
cout << "masukkan angka-angkanya \n";
for (int i=0;i<m; i++) {
cout << "a["<<i+1<<"] = ";
cin >> a[i];
}
}
void print (double *a, int n) {
for (int i=0; i<n; i++) {
cout << "a["<<i+1<<"] = "<<a[i]<<endl;
}
}
void sum (double*a, double*b, int n){
cout << "Hasil Penjumlahan : \n";
for (int i=0; i<n; i++) {
cout << a[i]+ b[i]<<endl;
}
Tidak ada komentar:
Posting Komentar