Hi, for this assignment I must allow the user to enter numbers into an array. When the array size exceeds 50 or when the user enters -999, the array will be displayed.
The problem: The sentinel value is not being recognized, so I am not sure if the program works correctly at all. Here is my code.
Code:
#include<stdio.h>
#include<stdlib.h>
#define SIZE 50
int main()
{
int value = 0, arr[SIZE] = {0}, i;
printf("Enter up to 50 numbers. Type and enter -999 to stop the loop: ");
while (arr[i] != -999 || arr[SIZE] < 50){
scanf_s("%i", &arr[i]);
printf("Enter a new number.\n");
}
for (i = 0; i < SIZE; i++){
printf("%i\n", arr[i]);
}
system("pause");
}
I would appreciate some help and advice. I've been working most of today to figure this out.