ToniDev

Suma nr. de 4 cifre

Dec 2nd, 2021
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int n, a;
  7.     int suma = 0;
  8.  
  9.     cout << "Introdu n: "; cin >> n;
  10.  
  11.     for (int i = 0; i < n; i++)
  12.     {
  13.         cout << "Introdu a: "; cin >> a;
  14.  
  15.         if (a >= 1000 && a < 10000)
  16.         {
  17.             suma += a;
  18.         }
  19.     }
  20.  
  21.     cout << "Suma: " << suma << endl;
  22.  
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment