I am having trouble getting the stars to output correctly in the printStars function. the final output should look something like this:
Enter a number(-1 to stop): 3
Enter a number(-1 to stop): 2
Enter a number(-1 to stop): 4
Enter a number(-1 to stop): -1
3
2
4
0: ***
1: **
2: ****
Here is what I have so far. But for some inputs it skips the output of the last index but for some numbers it doesnt skip... im quite confused.
Any help is greatly appreciated thank you!
yes line 40 is creating the issue since you are checking i value with content of the array at i'th position so it is skipping for some numbers
as suggested by tcs we cant use count also as we are not sure total array while will be filled or not. i mean user may read 5 entries and press -1 so i suggest following changes.