SHARE
TWEET

Untitled

a guest Sep 22nd, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     short int n, d, k, an;
  6.     bool isCorrect = false;
  7.     do
  8.     {
  9.         cout <<"\This program displays sequence elements\n";
  10.         cout << "\nEnter a value of k and d:\n";
  11.         cin >> k;
  12.         cin >> d;
  13.         isCorrect = true;
  14.         if ((k <= 0) || (d <= 0 ))
  15.         {
  16.             isCorrect = false;
  17.             cout << "\nEnter a value greater than zero\n";
  18.         }
  19.     } while (isCorrect);
  20.     an = 0;
  21.     n = 1;
  22.     while (n <= k)
  23.     {
  24.         an += an + n * d;
  25.         n++;
  26.         printf(an);
  27.     }
  28.     return 0;
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top