Ask Question
20 March, 07:30

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. 20 March, 08:28
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers