+ 3
My try:
#include<iostream>
using namespace std;
// declaring a function for your task
void task(int num){
int sum = 0, pro = 1;
while(num != 0){
dgt = (num%10);
num = int(num / 10);
sum += dgt;
pro *= dgt;
}
cout<<"Sum of digits: "<<sum;
cout<<"Product of digits: "<<pro;
}
int main(){
int n;
cout<<"Enter a number: ";
cin>>n;
// using the function with number
task(n);
return 0;
}