ToniDev

Produsul nr. cu ultima cifra 3

Dec 2nd, 2021
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int n, a;
  7.     int produs = 1;
  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 % 10 == 3) // 1234 % 10 = 4;   5512 % 10 = 2;   2142 % 100 = 42; 3 % 100 = 0.3
  16.         {
  17.             produs = produs * a;
  18.         }
  19.     }
  20.  
  21.     cout << "Produs: " << produs << endl;
  22.  
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment