Advertisement
satriafu5710

Menjumlahkan Deret dengan Lopping While C++

Dec 22nd, 2021
1,789
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.  
  7.     int batasDeret, i = 1, sum = 0;
  8.  
  9.     cout << "\n\t Menjumlahkan Deret dengan Looping While \n\n";
  10.  
  11.     cout << " Masukkan batas deret : ";
  12.     cin >> batasDeret;
  13.  
  14.     cout << "\n Deretnya : ";
  15.  
  16.     while (i <= batasDeret)
  17.     {
  18.         cout << sum << " + ";
  19.  
  20.         sum = sum + i;
  21.  
  22.         i++;
  23.     }
  24.  
  25.     cout << endl
  26.          << endl;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement