Computer Science, asked by akilacps38, 3 months ago

Accept 2 four-digit positive integers then calculate and display the sum of the product of each
pair of digits occupying the same position in the two numbers. [E.G. if the first number is 3445
and the second number is 4534 then the output will be 64.]
(Example: 3 * 4 + 4 * 5 + 4 * 3 + 5 * 4 = 64)

Answers

Answered by Rishabh5169
0

Answer:

#include <iostream>

using namespace std;

class brainliest {

public:

int getSum(int n)

{

int sum = 0;

while (n != 0) {

sum = sum + n % 10;

n = n / 10;

}

return sum;

}

};

int main()

{

brainliest g;

int n;

cout << "Enter Number: ";

cin>> n;

cout << g.getSum(n);

return 0;

}

I hope it will help you ◉‿◉

If it helps then mark me as BRAINLIEST PLEASE

Similar questions