Kasus 5.5



#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
            int a=0,b,c,jumlah=0,i,n;
            cout<<"Menghitung jumlah deret bilangan \n";
            cout<<"---------------------------------- \n";
            cout<<"Masukan bilangan awal : ";
            cin>>a;
            cout<<"Masukan beda : ";
            cin>>b;
            cout<<"Mesukan jumlah sampai deret ke-n : ";
            cin>>n;
            cout<<"Deret ke-"<<n<<" : ";
            cout<<a<<",";
            jumlah=jumlah+a;
            for(i=0; i<n-1; i++){
                        c=a+b;
                        a=c;
                        cout<<c<<",";
                        jumlah=jumlah+c;
            }
            cout<<"\n jumlah deret ke- "<<n<<" : ";
            cout<<jumlah;
           
           
            return 0;
}

 

 

Previous
Next Post »
Copyright © 2015 Bettong'rs All Right Reserved
Created by Arlina Design Powered by Blogger