ValerianBenchea

Suma primelor n numere pare

Oct 30th, 2019
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.23 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int i, s, n, nr=2;
  6.  
  7. int main()
  8. {
  9.  
  10.     cout<<"n=";
  11.     cin>>n;
  12.  
  13.     while(i<n)
  14.     {
  15.         s=s+nr;
  16.         nr=nr+2;
  17.         i++;
  18.     }
  19.          cout<<s;
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment