how do I convert this to a for loop
Show older comments
x = input('Enter a number between 1 and 100: ');
i = 0;
while x>0
x=x-i;
i=i+1;
end
fprintf('The while loop ran for %d interations\n' ,i)
Accepted Answer
More Answers (1)
David Hill
on 14 Apr 2020
Don't understand the purpose of the loop.
x = input('Enter a number between 1 and 100: ');
for i=1:x
end
fprintf('The for loop ran for %d interations\n' ,x)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!