# Error handling while running credit.c for pset1

I have broken the credit problem into 2 parts

1. Checking whether the sum after the Luhn’s algorithm has a zero at the end or not
2. If the inout integer is valid then go ahead and find the card type using switch.

for the 1st part have converted the integer into an array and then performed operations on odd and even numbers in the array to get the sum and check. But while running the code I'm getting the following errors

P.S - this my very first hands on experience at coding so please bear if this is a very native doubt.

``````#include <stdio.h>
#include <cs50.h>
#include <math.h>

int main(void)
{
long long n;
int c = 0;

printf("Enter an integer: ");
scanf("%lld", &n);

int numberArray[c];

while (n != 0)
{
numberArray[c] = n % 10;
n /= 10;
c++;
}
int sum_odd = 0;
int sum_even = 0;
int sum_total = 0;
for (int i = 1 ; i < c ; i+=2)
{
int x1 = 2* numberArray[i];
if (x1 >9)
{
x1 = x1%10 + x1%100 ;
}
sum_even = sum_even + x1 ;
}
for (int i = 0 ; i<c ; i+=2)
{
sum_odd = sum_odd + numberArray[i];
}
sum_total = sum_odd + sum_even;
if (sum_total % 10 != 0 )
{
printf ("Invalid\n");
}
}
`````` ``````int c = 0;
By doing this you declare `int numberArray` that is an array of zero members. So any index is "out of bounds" of this array, that is the mistake you see. Instead, you may want to declare an array of max number of members (16 if I remember correctly), and then fill it with digits (extracting digits from n one by one).