Advertisement
amrulHarahap

Program Menjumlahkan Deret Segitiga Siku-siku

Dec 19th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. // Program menentukan hasil penjumlahan deret bilangan genap segitiga siku-siku
  2. // Task No.2 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 , b, j,  jumlah;
  11.  
  12.     cout << "Input: "; cin >> a;
  13.  
  14.     for (b = 2; b <= a; b+=2){
  15.         jumlah = 0;
  16.        
  17.         for(j = 2; j <= b; j+=2){
  18.            
  19.             if(j!=2){
  20.                 cout << " + ";
  21.             }
  22.            
  23.             cout << j;
  24.             jumlah += j;
  25.         }
  26.         cout << " = " << jumlah << endl;
  27.     }
  28.  
  29.     cout << endl;
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement