How do I write a 'for' loop that starts counting from the given 'start' number? Without the first statement in the loop, the code will result in an error. Writing 'start = 0;' starts the counting from 0. Thanks in advance!
How do I write a 'for' loop that starts counting from the given 'start' number? Without the first statement in the loop, the code will result in an error. Writing 'start = 0;' starts the counting from 0. Thanks in advance!
You can leave the initial statement blank and just put a semicolon.
for(; start <= end; start++)
Just do:
for(int i = start; i <= end; i++){
end--;
System.out.print(start);
}
Although in actuality if you want your code to work you have to do:
for(int i = start; i <= end; i++){
System.out.print(start);
}