I'm not familiar with Octave, but here are some examples we use for while loops:
Collect a user's input until it is the correct type (such as asking the user for a number)
Find a running sum of numbers until a user inputs 0
A piggy bank that collects coins (represented by single-letter user inputs) that provides a total balance only after the user inputs &...
The collatz conjecture is a great example of a while loop:
start with any number
if it's even, divide by 2
if it's odd, times three and add 1
stop if you ever reach 1. (what happens if you continue?)
The conjecture that you'll always reach 1 is just about the easiest to explain, hardest to prove, statement in math. As in: still open.
For students to ...
Look at the scratch resources at NCCE.
Scratch is a graphical block based language designed for kids to learn programming.
The National Centre for Computing Education, have produced various teaching resources. As an experienced programmer, and new teacher, I used these as is the first time, then started adapting them.
Now I have another favorite example called "Buy Low, Sell High", all the credit go to this article https://realpython.com/numpy-array-programming/#buy-low-sell-high
Given a stock’s price history as a sequence, and assuming that you are only allowed to make one purchase and one sale, what is the maximum profit that can be obtained? For example, ...