Hello, I'm trying to finish a project that has a 4-digit number multiply each digit together in order to receive a product number. Here is what I have:
#include <iostream>
using namespace std;
int main()
{
int whole_num;
int digit1, digit2, digit3, digit4; //digits = the 4 digits in the whole_num
int num1, num2, num3; //nums = the nums outputted in order to get the digits
int product_num; //The product number that has each digit mulitplied
cout<< "Hello, please enter a 4-digit whole number. \n";
cin>> whole_num;
digit1 = whole_num/1000;
num1= digit1%1000;
digit2= num1/100;
num2= digit2%100;
digit3= num2/10;
num3= digit3%10;
digit4= num3/1;
product_num= digit1*digit2*digit3*digit4;
cout<< "The product of all the digits multiplied together is.. \n" << product_num << endl;
//Shows the user what the product of each digit is when multiplied together
system ("pause");
return 0;
}
It runs, but the product is always 0. What did I do wrong?