Hi,
I have a system that now specifies from the user a value to determine the size of an array. the user can then enter value into the array one by one, until they get to the limit specified, all that works fine.
The array I have created is for input values for an AND gate. The AND gate will only produce a 1 if all the values in the array are set to 1. the way I want to get it is that I run a for loop through the AND array of values for the inputs and the first value that it encounters that is a 0, it will run the printf statement that reads 0.
I can't seem to get it to do it, it always seems to evalate to 1, even thought i have placed a 0 in the array.
here is a snippet of where I am stuck, any ideas will be great, thanks for listeningCode:int and(int inputs) { printf("\nPlease Set The Vlues For Your Inputs: "); int array[inputs]; int i =0; for (i = 0; i < inputs; i++){ printf("Enter input %d:", i); scanf("%d",&array[i]); } for (i=0; i<inputs; i++) { printf("\n%d", array[i]); } if (array[i] == 0) { printf("output = 0"); } else { printf("output = 1"); }