skip to main | skip to sidebar

Sedikit Ilmu Yang Berguna

  • Entries (RSS)
  • Comments (RSS)
  • Home
  • About Us
  • Archives
  • Contact Us

Tuesday, April 19, 2011

deret

Posted by randiadma at 12:03 AM
#include <iostream.h>

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<<"hasil penjumlahan deret = "<<jumlah;
    return jumlah;
    }

    int main()
    {
    cout<<"program sederhana menghitung jumlah dari rumus 1-(1/2)+(1/3)-(1/4)+...+(1/n)"<<endl<<endl;
    cout<<"tentukan nilai n : ";
    hitung deret;
    deret.input();
    deret.proses();
   
    return 0;
    }
Email This BlogThis! Share to X Share to Facebook

0 comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Sponsored

  • banners
  • banners
  • banners
  • banners

Blog Archive

  • ►  2012 (61)
    • ►  June (2)
    • ►  May (9)
    • ►  April (19)
    • ►  March (27)
    • ►  February (1)
    • ►  January (3)
  • ▼  2011 (44)
    • ►  December (2)
    • ►  November (11)
    • ►  October (1)
    • ►  September (5)
    • ►  May (1)
    • ▼  April (16)
      • bilangan 3 dan 5
      • deret
      • rekursif
      • BBM
      • tugas deret suku
      • alpro3
      • alpro2
      • alpro
      • c++ part 2
      • c++ part 2
      • c++
      • c++
      • c++
      • part 1
      • jeliot 2
      • jeliot
    • ►  March (8)

Followers

Clock Widgets

About Me

My photo
randiadma
Saya Mahasiswa UAD, Jurusan Teknik Informatika,
View my complete profile

My Fuckkn Facebook

Randy Mix Emax

Buat Lencana Anda

Followers

Powered by Blogger.

Blog Archive

  • ►  2012 (61)
    • ►  June (2)
    • ►  May (9)
    • ►  April (19)
    • ►  March (27)
    • ►  February (1)
    • ►  January (3)
  • ▼  2011 (44)
    • ►  December (2)
    • ►  November (11)
    • ►  October (1)
    • ►  September (5)
    • ►  May (1)
    • ▼  April (16)
      • bilangan 3 dan 5
      • deret
      • rekursif
      • BBM
      • tugas deret suku
      • alpro3
      • alpro2
      • alpro
      • c++ part 2
      • c++ part 2
      • c++
      • c++
      • c++
      • part 1
      • jeliot 2
      • jeliot
    • ►  March (8)
 

© 2010 My Web Blog
designed by DT Website Templates | Bloggerized by Agus Ramadhani | Zoomtemplate.com