Stack Overflow Asked by A P Jo on September 10, 2020
I’m using int er[3001]
. I’ll be taking user input, but it is unlikely that entire array size will be used.
In a char
array / string, one would simply set a for loop testing arr[i] !=
. How is this effect achieved for an int
array ?
I’m assuming using the same exact condition won’t work?
I'm assuming using the same exact condition wont work ?
You're right in this, there's no default sentinel value for marking the end of integer array. You need to either:
-1
, when all expected inputs are non-negative) and get to the first invalid value location after the input.Correct answer by Sourav Ghosh on September 10, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP