Ask Question
12 January, 09:52

Write a script file that creates a row vector v containing all the powers of 2 that are (strictly) less than 103. The output vector should have the form: v = [2, 4, 8, 16 ... ]. Use the while loop.

+4
Answers (1)
  1. 12 January, 11:37
    0
    v = [];

    %intitialze variable pow with 2

    pow = 2;

    %repeat the while loop until pow doesn't exceed 1000

    while pow <103

    %add pow to v

    v = [v, pow];

    %Generate next number that is power of 2

    pow=pow*2;

    end

    %Print the row vector

    v
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a script file that creates a row vector v containing all the powers of 2 that are (strictly) less than 103. The output vector should ...” 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