Inverse of number

pls tell me what is wrong with my code
ques


code
#include

using namespace std;

int main() {

int num,inv = 0;

cin>>num;

int k = 1;

int k1 = 1;

int k2 = 1;

for(int i = 1; num != 0; i++) {

    k2 = k;

    int ext = num%10;

    for(int j = 1; j <= ext && ext != 1; j++) {

        k1 = k2 * 10;

        k2 = k1;

    }

    inv = inv + k1;

    num = num/10;

    k = k +1;

}

cout<<inv;

}

hi @vishnuchopra58_67b7b96e3108c15e,
U misinterpreted the question buddy…
Inverse is here basically inverting the places of any number with its value.

For e.g…,
Before Inverse

  • Places --> 5 4 3 2 1
  • Value —> 3 2 1 4 5

eg : 32145 answer is 12543
here u have got the place of numbers in input
for 1 is 5
for 2 is 4
for 3 is 1
for 4 is 2
and for 5 is 3
just place them in this order 12543

After Inverse

  • Places --> 5 4 3 2 1
  • Value —> 1 2 5 4 3
Algo

1.Declare a Place variable that will keep track of the place number for which we are processing the work.
2.The value can be extracted by performing modulus operator on the given number.
3.In order to inverse the place and the number extracted in points 1 and 2 multiply the place with 10 ^ (rem - 1).
For e.g…, Place = 4 and rem = 3, then multiply place with 100 viz, ( 10 ^ (rem - 1)). 4.Add the number to the previous ans.

for implementation difficulties refer https://ide.codingblocks.com/s/662530

Thank you!!!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.