Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int MultipliedSum(int odd, int even){
- return odd * even;
- }
- int EvenOrOdd(int singles){
- //checking if the digit is odd or even
- return singles % 2;
- }
- int main()
- {
- int num = -12345;
- // cin >> num;
- int evenSum, oddSum, singles = 0;
- while (num)
- {
- singles = num % 10; //getting the last digit from the number
- if ( EvenOrOdd(singles) )
- {
- evenSum += singles;
- }
- else
- {
- oddSum += singles;
- }
- num /= 10; // removing the last digit from the number
- }
- cout << MultipliedSum(oddSum, evenSum);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement