Answer to Question #312830 in C++ for All

Question #312830

Write a program which takes a 9-digit number input from user, converts it into its reverse and then display one of the following statements: (


• Original number is x steps bigger (where x is the difference between the two) •


Reversed number is x steps bigger


• Both numbers are equal; hence it is a palindrome.

1
Expert's answer
2022-03-16T18:31:32-0400

Here is program:

int main()
{
    int t, a, p;
    cin >> t;
    int* s = new int[t];
    for (int i = 0; i < t; i++)
    {
        cin >> p >> a;
        b = 1;
        while ((a * b - 1) % p != 0)
        {
            b++;
        }
        s[i] = b;
    }
    for (int i = 0; i < t; i++)
    cout << s[i] << endl;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment