title: Using if statements with strings in c++
body: <p>I am trying to perform binary addition using strings. When using if statement, I am always getting the output "did not go in ifs". Please help me and tell me if I am doing any bad practice or any error. Beginner in c++.</p>
  
  <pre><code>while(k &gt;= 0)
  {
      if (Bin_input1[k] == 0 &amp;&amp; Bin_input2[k] == 0)
      {
          if (carry == 0)
          {
              Bin_output[k] = 0;
              cout &lt;&lt;Bin_output[k] &lt;&lt; endl;
              carry = 0;
              k = k-1;
          }
          else
          {
              Bin_output[k] = 1;
              cout &lt;&lt;Bin_output[k] &lt;&lt; endl;
              carry = 0;
              k = k-1;
          }
      }
      else if (Bin_input1[k] == 0 &amp;&amp; Bin_input2[k] == 1)
      {
          if (carry == 0)
          {
              Bin_output[k] = 1;
              cout &lt;&lt;Bin_output[k] &lt;&lt; endl;
              k = k-1;
          }
          else
          {
              Bin_output[k] = 1;
              cout &lt;&lt;Bin_output[k] &lt;&lt; endl;
              carry = 1;
              k = k-1;
          }
      }
      else if (Bin_input1[k] == 1 &amp;&amp; Bin_input2[k] == 0)
      {
          if (carry == 0)
          {
              Bin_output[k] = 1;
              cout &lt;&lt;Bin_output[k] &lt;&lt; endl;
              k = k-1;
          }
          else
          {
              Bin_output[k] = 1;
              cout &lt;&lt;Bin_output[k] &lt;&lt; endl;
              carry = 1;
              k = k-1;
          }
      }
      else if (Bin_input1[k] == 1 &amp;&amp; Bin_input2[k] == 1)
      {
          {
              Bin_output[k] = 1;
              cout &lt;&lt;Bin_output[k] &lt;&lt; endl;
              carry = 1;
              k = k-1;
          }
      }
      else
          cout&lt;&lt; "did not go in ifs" &lt;&lt; endl ;
  
      k = k - 1;
  }
  return Bin_output;
  </code></pre>