Advertisement
amrulHarahap

Program Perkalian Deret Ganjil Segitiga Siku-siku

Dec 19th, 2019
96
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 perkalian deret bilangan ganjil segitiga siku-siku
  2. // Task No.3 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 i , j, k,  jumlah;
  11.  
  12.     cout << "Input: "; cin >> i;
  13.  
  14.     for (j = 1; j <= i; j+=2){
  15.         jumlah = 1;
  16.        
  17.         for(k = 1; k <= j; k+=2){
  18.            
  19.             if(k!=1){
  20.                 cout << " * ";
  21.             }
  22.            
  23.             cout << k;
  24.             jumlah *= k;
  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