Advertisement
Rehan_Rahman26

Product of Digits

Sep 28th, 2021
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int a,b,c,d,i,tot,flg=0;
  6.     cin >> a;
  7.     for(i=1; i<=9; i++)
  8.     {
  9.         if(a%i==0)
  10.         {
  11.             b=i;
  12.             d = a/i;
  13.             flg ++;
  14.         }
  15.         tot = d*10+b;
  16.     }
  17.     if(flg==0 || tot>=100)
  18.         cout << "-1" << endl;
  19.     else
  20.       cout << tot << endl;
  21.     return 0;
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement