Ask Question
27 June, 04:57

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.

+2
Answers (1)
  1. 27 June, 07:43
    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?
Get 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 & 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