title: How to convert binary to decimal in C
body: <p>I would like to convert a series of integers to decimal. I know the procedure but how can I put all integers as one binary number?</p>
  
  <p>Output has to be like this:</p>
  
  <pre><code>Enter first binary digit: 0
  Enter second binary digit: 0
  Enter third binary digit: 0
  Enter fourth binary digit: 0
  0000 = 0
  </code></pre>
  
  <p>The following is how I wrote this task:</p>
  
  <pre><code>#define _CRT_SECURE_NO_WARNINGS
  #include&lt;stdio.h&gt;
  #include&lt;conio.h&gt;
  
  int main(void)
      {
          int a[100];
          int n, dec = 0; int power(int, int);
  
          long int binaryNumber, decimalNumber = 0, j = 1, remainder;  
  
          printf("Enter first binary number: ");
          scanf("%ld", &amp;a[1]);
          printf("Enter second binary number: ");
          scanf("%ld", &amp;a[2]);
          printf("Enter third binary number: ");
          scanf("%ld", &amp;a[3]);
          printf("Enter fourth binary number: ");
          scanf("%ld", &amp;a[4]);
  
          for (int i = 0;i&lt;n;i++)
          {
              scanf("%d", &amp;a[i]);
          }
  
          for (int i = (n - 1);i &gt;= 0;i--)
          {
              dec = (a[i] * power(2, j)) + dec;
              j++;
          }
          printf("binary number of decimal is %d", dec);
  
          return 0;
      }
  </code></pre>