Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n, i,x,s;
- cout << "Dati numarul de elemnte: ";
- cin >> n;
- i = 1;
- while (i <= n)
- {
- cout << "Dati un alt element: ";
- cin >> x;
- if (x % 2 == 1)
- {
- cout << "Ultima cifra a numarului este " << x % 10;
- cout << "\n";
- }
- else {
- s = 0;
- while (x > 0)
- {
- s = s + x % 10;
- x = x / 10;
- }
- cout << "Suma cifrelor este " << s;
- cout << "\n";
- }
- i++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement