- 1
How to use 'if' in array (c language)?
Example : If i want to use 'if' in basic integer, i can write like this : If(a >= 1 && a <= 100) {} But, how i write it in array? I can't write like this : If(a[] >= 1 && a[] <= 100) {} P.s : It contains 6. Float a[6];
3 Antworten
+ 2
You can setup a loop (whichever loop) to traverse the array from index 0 up to index 5 (for 6 elements). Then for each round of the loop, you check whether an element at index <i> is within range.
if(a[i] >= 1 && a[i] <= 100)
+ 2
No problem 👌
Happy coding 👍
+ 1
Thank you so much 🤗