Search the courses, subjects, tracks, games and features, or jump straight to a page.
3 cards from this section. Quick, good the night before a test.
What is the main purpose of a while loop?
Think about when you would want to run something multiple times.
How would you stop an infinite loop in MATLAB?
What key combination is often used to interrupt a command?
What does the while loop do in MATLAB?
Think about when you want to repeat something conditionally.
True or False: A while loop will always terminate if its condition is true.
Consider what happens in an infinite loop.
Create a MATLAB script that uses a while loop to read user input until the user types 'exit', tally the number of inputs received, and display it after exiting.
Consider how to compare strings in MATLAB and increment a counter.
Write a MATLAB function using a while loop that returns the factorial of a number. The function should prompt the user for input and continue to do so until a positive integer is given.
Think about validating the input to ensure it's a positive integer.
5 more questions in this section. Enroll free to practise them all.
Enroll free