# Thread: Int Array - Stop taking values at [zero]

1. ## Int Array - Stop taking values at [zero]

I'm working on an integer array. I have it to accept exactly ten values. How can I make it accept UP TO ten numbers, and stopping if a zero is entered? I should probably be using a WHILE loop instead?

Here's a snippit of some code from my program.

Code:
```     void main (void)

int numbers[10];
int x;

printf("Enter 10 numbers\n");

for(x=0; x<=9; x++)
{
printf("Number %d:", x+1);
scanf("%d", &numbers[x]);
}```

2. Originally Posted by bunko
I'm working on an integer array. I have it to accept exactly ten values. How can I make it accept UP TO ten numbers, and stopping if a zero is entered? I should probably be using a WHILE loop instead?

Here's a snippit of some code from my program.

Code:
```int main (void)
{
int numbers[10];
int x;

printf("Enter 10 numbers\n");

for(x=0; x<=9; x++)
{
printf("Number %d:", x+1);
scanf("%d", &numbers[x]);
if(numbers[x] == 0)
break;
}
}```
Nope. Just do that.

3. Thank you!

4. No problem dude