Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

4. Basic While Loop O solutions submitted (max: Unlimited) The test suite assign

ID: 3713025 • Letter: 4

Question

4. Basic While Loop O solutions submitted (max: Unlimited) The test suite assigns a random number to the variable Number. Write a script that uses a while loop to repeatedly divide this number by 7 until the value remaining is less than 1. Assign the result to the variable WhatsLeft. Keep track of the number of divisions required and assign to the integer variable DivisionCount. Your Script C Reset MATLAB Documentation 1 %Enter commands in the space below to implement the while loop that is specified in the problem statement. Note the value of the var 3 #TYPE Assessment Run Pretest Submit

Explanation / Answer

Number = 10;% the input random no
Whatsleft=Number;
DivisionCount=0;
while( Whatsleft>1 )% basic while loop which checks the condition for the no to be divided is greater than 1
Whatsleft=Whatsleft/7;
DivisionCount=DivisionCount+1;
end
fprintf('value of Whatsleft: %d ', Whatsleft);
fprintf('value of DivisionCount: %d ', DivisionCount);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote