Răspuns :
Răspuns:
#include <iostream>
using namespace std;
int main(){
int n;
int s = 0;
cout << "n=";
cin >> n;
int c;
while (n) {
c = n % 10;
if (c == 5){
s += c;
}
n /= 10;
}
cout << "Suma cifrelor egale cu 5 : " << s << endl;
return 0;
}
_______________________________________________
#include <iostream>
using namespace std;
int main(){
int n;
int p = 1;
cout << "n=";
cin >> n;
int c;
while (n) {
c = n % 10;
if (c > 4 && c % 2 == 0){
p *= c;
}
n /= 10;
}
cout << "Produsul cifrelor pare mai mari ca 4 : " << p << endl;
return 0;
}
________________________________________________________
#include <iostream>
using namespace std;
int main(){
int n;
cout << "n=";
cin >> n;
if (n > 3){
for (int i = 2;i <= n; i += 2){
cout << i << ' ';
}
} else {
cout << "2 " << endl;
}
cout << endl;
return 0;
}
Explicație: