Ask Question

Using a while loop, write a code that will continue to calculate the following equation until the solution gets to be above 100, x will start at zero. What is the final solution and how many iterations does it take to complete (prob05) as a row vector.

+2
Answers (1)
  1. 28 November, 10:41
    0
    prob05. m

    clc

    x=0;

    sum=0;

    iteration=0;

    while (sum<100)

    x=2*x+1;

    sum=sum+x;

    x=x+1;

    iteration=iteration+1;

    end

    fprintf ('total iteraton take to sum greater than 100 is %d and sum becomes %d/n', iteration, sum);
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Using a while loop, write a code that will continue to calculate the following equation until the solution gets to be above 100, x will ...” 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