#include <cstdlib>
#include <iostream>

using namespace std;

class deret{
      public :
             deret();
             int tampil(int x,int b,int n);
      private:
              int x,b,n;
              };
             
deret::deret()
{cout<<"\t\t\tPenjumlahan deret aritmatika"<<endl<<endl;
}
int deret::tampil(int x,int b,int n){
   
   
    if(n==0){
             return 0;
             }
    else {
         return ((x+(n-1)*b)+tampil(x,b,n-1));
         }
}
             
     
int main(int argc, char *argv[])
{
    int p,q,r;
    deret i;
    cout<<"Masukkan batas awal : ";cin>>p;
    cout<<"Masukkan beda : ";cin>>q;
    cout<<"Masukkan banyak deret : ";cin>>r;
    for(int s=0;s<r;s++)
    {
          
    cout<<p+s*q<<" ";
    }
    cout<<"\nJumlah dari seluruh deretnya adalah : "<<i.tampil(p,q,r)<<endl;;

    system("PAUSE");
    return EXIT_SUCCESS;
}

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Popular Post

- Copyright © Irhaz Share -Irhaz Matru- Powered by Blogger - Design by Irhaz Rangga Kala -