Loops | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Loops

How could I edit my code Using a while loop and two if statements to not print number less than 5 and numbers greater than 10 in the array? https://code.sololearn.com/ciGpJ07RJVEd/?ref=app

7th Jan 2019, 5:05 PM
farhan bhatti
farhan bhatti - avatar
2 Answers
+ 2
#include <stdio.h> int main() { int array[] = {1, 7, 4, 5, 9, 3, 5, 11, 6, 3, 4}; int i = 0; int arraysize = 11; while (i < arraysize) { if (array[i] < 5) { i++; continue; } if (array[i] > 10) { i++; continue; } printf("%d\n", array[i]); i++; } return 0; }
7th Jan 2019, 5:57 PM
MS Kashef
MS Kashef - avatar
+ 1
Thanks for help, i knew i was doing something wrong but wasnt sure.🙈
7th Jan 2019, 6:36 PM
farhan bhatti
farhan bhatti - avatar