Hello, please help.
I need a c++ code: to calculate the sum and product of the figures of
three-digit number entered. (e.g. cin >> a; (eg. a = 123) cout << “The sum is 6, The product is 6”<<;
Pleasee help me.
Hello, please help.
I need a c++ code: to calculate the sum and product of the figures of
three-digit number entered. (e.g. cin >> a; (eg. a = 123) cout << “The sum is 6, The product is 6”<<;
Pleasee help me.
Hey @coutAbc! Welcome to the forums!
If you take in your ‘a’ as a string, you can parse out the string into 3 characters, and then convert those characters into ints, for example:
char a = '2';
int numA = a - 48 (the '-48' is due to ascii so '2' (50) - 48 = 2)
You will then have your three numbers and can run all of your checks.
I hope the above is the solution you need!
Thank you so much.
Hey @coutAbc,
You’re welcome! Did the above solve your problem?