I am getting wrong answer

how to convert negative no into char

@anyamaurya please explain your doubt your doubt a little more, like “what do mean by converting a negative number into char”, its all depend upon the ascii values.

I mean that in the sample input acb the difference between c and b is -1 ,so how can i concert it into char as it is negative

@anyamaurya
here you don’t need to convert it into char, just take the two character and find the difference.
Then, print first char then diff then second char.

@anyamaurya

you can do it like this:-

    cout<<s[0];
    for(int i=1; i<s.size(); i++) {
        int diff = s[i]-s[i-1];
        cout<<diff<<s[i];
    }