Ask Question
12 December, 01:36

Convert for loop to while loop, that is the script

z1=zeros (10);

for x=1:10

for y=1:10

z1 (x, y) = x^2-3*y

end

end

z1

+1
Answers (1)
  1. 12 December, 01:43
    0
    To convert for loop to while loop we have to first declare and initialize the integers or variables that will work as an counter.

    script will be

    z1=zeros (10);

    x=1

    while x<10

    y=1

    while y<10

    z1 (x, y) = x^2-3*y

    y=y+1

    end

    x=x+1

    end

    z1

    Remember that we have to update the counter every time that we not need to be done for loop.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Convert for loop to while loop, that is the script z1=zeros (10); for x=1:10 for y=1:10 z1 (x, y) = x^2-3*y end end z1 ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers