csansoon

P3.12 P61061 Product of digits

Oct 10th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main () {
  5.     int n, m=1;
  6.     while (cin >> n) {
  7.         cout << "The product of the digits of " << n << " is ";
  8.             m=1;
  9.             while (n>=10) {
  10.                 m=m*(n%10);
  11.                 n=n/10;
  12.             }
  13.             n=m*n;
  14.             cout << n << "." << endl;
  15.         while (n>0 && n%10!=n) {
  16.            
  17.             cout << "The product of the digits of " << n << " is ";
  18.             m=1;
  19.             while (n>=10) {
  20.                 m=m*(n%10);
  21.                 n=n/10;
  22.             }
  23.             n=m*n;
  24.             cout << n << "." << endl;
  25.         }
  26.         cout << "----------" << endl;
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment