2
Reply

Why is count used instead of array length

Komolafe Yonusimi

Komolafe Yonusimi

Jan 18 2018 10:01 AM
169
Please I am a beginner to programming, why is count used in the for loop so far it is 0 and not if i is less than the number array length.
  1. count = 0  
  2. for (int i = 0; i < count; i++)  
  3. if (numbers[i] == searchNumber)  
  4. found = true;  
  5. if (found)  
  6. Console.WriteLine("Number {0} found a amount of {1} "  
  7. , numbers[i]);  
  8. else  
  9. {  
  10. Console.WriteLine("Not found");  
  11. found = false;  
  12. }  
  13. break;  

Answers (2)