Write a script that will: generate a random integer in the inclusive range from 2 to 5 loop that many times to o prompt the user for a number o print the sum of the numbers entered so far with one decimal place
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:5| Question number:7.5
All Answers
total answers (1)
Ch5Ex7.m
% Generate a random integer and loop to prompt the
% user for that many numbers and print the running sums
ranint = randi([2,5]);
runsum = 0;
for i = 1:ranint
num = input('Please enter a number: ');
runsum = runsum + num;
fprintf('The sum so far is %.1f\n', runsum)
end
need an explanation for this answer? contact us directly to get an explanation for this answer