title: C++ if statement over 4 digits
body: <p>im writing a program to convert a four digit octal number to a decimal number. I have to do this programs using charactes. <strong>no char rays or strings says my lecturer</strong>. does anybody no how i can do this? here is my code: </p>
  
  <pre><code>int main() {
  
    char a = 0;
    char b = 0;
    char c = 0;
    char d = 0;
  
    cout &lt;&lt; "Enter 4 digit octal number ";
    cin &gt;&gt; a &gt;&gt; b &gt;&gt; c &gt;&gt; d;
    if (a - '0' &gt; 7 || b - '0' &gt; 7 || c - '0' &gt; 7 || d - '0' &gt; 7 || !isdigit(a)
        || !isdigit(b) || !isdigit(c) || !isdigit(d)) {
      cout &lt;&lt; "Bad data";
    }
    else
      cout &lt;&lt; "Decimal form of that number: " &lt;&lt; ((a - '0') * 512) + ((b - '0')
          * 64) + ((c - '0') * 8) + (d - '0') &lt;&lt; endl;
  
    return 0;
  }
  </code></pre>