Please tell the error

INPUT: 123456789
MY OUTPUT: 1654987
Expected Output: 321654987

Please have a look over this query

your logic is correct
problem: -

  1. before calling reversal() function at line 84, you should first make a temporary node to store the address of new reversal list
    node *temp=NULL;
    because head pointer value is changing in reversal function at line 65

  2. before printing give space at line 74
    cout<data<<" ";