Write a C++ program to calculate product of digits of a number.
using namespace std; int product(int number){ int prod = 1, i; for(i=number; i>0; i=i/10) { prod = prod*(i % 10); } return prod; } int main(){ int n; cout<<"Enter int N: "; cin>>n; cout<<product(n)<<endl; }
Need a fast expert's response?
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Comments