I have an array of 20 elements with numbers between 1 and 8. I need a for loop that will give me the number of elements greater than 1???
Jump to Post
Create another variable to store the number of 1's. You go through all elements of the array and each time it equals 1 you increment that variable by 1.
You could think of that by yourself ain't that hard.
All 5 Replies
Be a part of the DaniWeb community
We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.