ToniDev

Numarul numerelor care se termina cu 5

Nov 26th, 2021 (edited)
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int n, suma = 0, a;
  7.  
  8.     cout << "Introdu n: "; cin >> n;
  9.  
  10.     for (int i = 1; i <= n; i++)
  11.     {
  12.         cout << "introdu a: "; cin >> a;
  13.  
  14.         if (a % 10 == 5)
  15.             suma++;
  16.     }
  17.  
  18.     cout << "Suma nr. cu ultima cifra 5: " << suma;
  19.  
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment