Ask Question
21 December, 18:54

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.

+3
Answers (1)
  1. 21 December, 19:09
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers