How would I explicitly state this positive condition? [SOLVED]
I just wrote a code in an attempt to scan into an array and print 5 integer values , so long as they are positive. When a negative number is given, or the request of 5 positive integers has been satisfied, the code will output the given integers. For some reason, my code does everything right except it still accepts negative integers. Can someone take a look at it and see where I am going wrong? My suspicions lie in the darned syntax... \#include <stdio.h> ​ int main(void){ int count=0; int x; // TODO: Declare array named values\[ \] with five elements int values\[4\]; // TODO: Obtain array input until a negative value or // more than five are entered while (count<5 && x>=0){ scanf("%i",&x); values\[count\] = x; \++count; } // Print array values printf("%i values entered: ",count); for (int i=0; i < count; i++) { printf("%i ",values\[i\]); } return 0; }