-Black Inspiration- -Telor-ceplox- -PROFIL- -Facebook- -Twitter- "* ikhsan_choco@ymail.com "*
Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!!----Stop Dreaming and Start Action Now...!! Jangan lupa kasih komentar demi kemajuan blog ini...!!!

20 Apr 2011

C++ : menghitung deret N

 program yg saya buat ini adalah tugas postes praktikum Algoritma dan pemograman. awalnya saya begitu bingung dengan algoritma yang djelaskan ASDOS algoritma,,tp yaaaa lama-lama bisa juga walau pun baynyak tanya sama asdosnya. langsung download programya disini lalu coba lihat algoritmnya dan program c++


ALGORITMA PEMROGRAMAN

1.inisialisasi semua variabel (i,N,Jumlah)
2.masukkan nilai N
3.inisialiasi jumlah = 0
4.for (i=1; i<=N; i++) {jumlah = jumlah + i ;}
5.printf(jumlah)

PRPGRAM C++ :

#include <cstdlib>
#include <iostream>

using namespace std;

class hitung
{
     
public:
       int proses();
       void input();

private:
        int n;
        float rumus,jumlah,total;
};

void hitung::input()
{
     cin >> n;
     cout << endl;
}
   
int hitung::proses()
{
    jumlah = 0;
    total = 0;
    rumus = -1;

          for(int j=1; j<=n; j++){
                  rumus = (rumus * (-1));
                  total = rumus / j;
                  jumlah+= total;
                  if(j==1)
                  cout << " ( " << total << " ) ";
                       if( j > 1)
                           cout << " + ( " << total << " ) ";
}

cout << endl << endl << " Jumlah Rekursif = " << jumlah;
cout << endl;

return jumlah;
}

int main(int argc, char *argv[])
{
    cout << " Program Menghitung Jumlah dari Dumus 1-(1/2)+(1/3)-(1/4)+...+(1/n) ";
    cout << endl;
    cout << endl;
    cout << " Masukkan Nilai n : ";
   
    hitung deret;
    deret.input();
    deret.proses();
   
    system("PAUSE");
    return EXIT_SUCCESS;
}

Tidak ada komentar:

Posting Komentar