How to use 'if' in array (c language)? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 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];

6th Oct 2020, 1:37 PM
Briana
Briana - avatar
3 Answers
+ 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)
6th Oct 2020, 1:46 PM
Ipang
+ 2
No problem 👌 Happy coding 👍
6th Oct 2020, 2:07 PM
Ipang
+ 1
Thank you so much 🤗
6th Oct 2020, 2:06 PM
Briana
Briana - avatar