Alright so pretty much the program is supposed to have values entered in until the user inputs a "-1", then the program is supposed to stop asking. Also, no negative numbers below -1 are allowed but the code is supposed to keep asking until there is a positive number. I've done this before just never with an array. Any help is appreciated and I can post the assignment description if needed. I've been fooling around with it for a while but this is my original code i've been starting from scratch from.
Code:
#include <stdio.h>
#include <stdbool.h>
int getBoard ();
bool validate (int lengths[*]);
int main (void)
{
getBoard ();
return 0;
}
int getBoard ()
{
int lengths[10]; //ARRAY FOR ALL THE TRIANGLES SIDE LENGTHS
int n; //COUNTER FOR THE ARRAY
bool valid; //TO CHECK TO SEE IF THE INPUT IS NOT NEGATIVE
do
{
for(n = 0; n < 10; n++)
{
printf("Enter the length of board #%d: ", (n + 1));
scanf("%d", &lengths[n]);
}
valid = validate (lengths);
if (!valid)
{
printf("Invalid negative input! Please try again!");
}
}while(!valid);
return lengths[10];
}
bool validate (int lengths[10])
{
bool valid = true; //BOOLEAN TO VALIDATE VALUES
if (lengths[10] < -1)
{
valid = false;
}
return valid;
}