I'm trying to write a c program that reads a barcode(that is 10 digits long) from stdin, adds up the first 9 digits of the barcode, and if the second digit of the sum of the 9 digits is equal to the 10th digit in the barcode it writes the barcode to stdout.

Here is what I have so far, can some one please help me or tell me what wrong with what i've got or what to add. would it be possible to put the whole barcode into a character array and sum the first 9 digits and compare it to the value of bar[9]? how would i do this?
Thanks

```
#include <stdio.h>

int main(void){
  int sum = 0;
  char bar[10];
  int i;
  for(i = 0; i < 9; i++){
    scanf("%d", &bar[i]);
  }

  for(i = 0; i < 10; i++){
     sum += bar[i];
  }

  if(sum[1] == bar[10]){
      return 1;
  }
  return 0;
}

```