Advertisement
amrulHarahap

Program Menjumlahkan Deret

Dec 19th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. // Program menentukan hasil penjumlahan deret 10 bilangan
  2. // Task No.1 file 066-P05.pptx
  3. // Amrul Mubarak Harahap
  4. // 19T03 - 1901098
  5.  
  6. #include <iostream>
  7. using namespace std;
  8.  
  9. int main(){
  10.     int a = 2, b = 20, n, total, i;
  11.  
  12.     for (int i = a; i <= b ; i+=2){
  13.         cout << i;
  14.  
  15.         if (i < b){
  16.             cout << " + ";
  17.         }
  18.     }
  19.  
  20.     cout << " = ";
  21.     n = b/2;
  22.     n = n*(n+1);
  23.  
  24.     cout << n;
  25.  
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement