title: SPOJ wrong answer ADDREV
body: <p>My code is quite simple and straightforward. I get "wrong answer" on submission though. I have no clue why that happens! Here is the code...</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;string&gt;
  using namespace std;
  
  void sum(string num)
  {
    int i,len=num.length();
    int j=len-1;
    int carry=0;
    string answer;
    int s=0;
    for(i=0,j;i&lt;len;i++,j--)
    {
      s = (num[i]-'0')+(num[j]-'0')+carry;
  if (s&gt;10&amp;&amp;j!=0)
  { 
        carry = s/10;
    s = s%10; 
      } 
  else if (s&gt;10&amp;&amp;j==0)
  { 
        carry=s/10; s=s%10; answer+=s+'0';answer+=carry+'0'; break;
      }   
  answer+=s+'0';
    }
    int sz=answer.size();for(int j=sz-1;j&gt;=0;j--) cout&lt;&lt;answer[j];
    }
  
    int main(int argc,char **argv)
    {
      int n;cin&gt;&gt;n;
      for(int i=0;i&lt;n;i++)
    {
    string no;cin&gt;&gt;no;
    sum(no);cout&lt;&lt;endl;
    }
  }
  </code></pre>