Write a script that will generate random integers in the range from 0 to 50, and print them, until one is finally generated that is greater than 25. The script should print how many attempts it took
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:5| Question number:21.5
All Answers
total answers (1)
Ch5Ex21.m
rani = randi([0 50]);
fprintf('The integer is %d\n', rani)
count = 1;
while rani <= 25
rani = randi([0 50]);
fprintf('The integer is %d\n', rani)
count = count + 1;
end
fprintf('Yay, a %d! It took %d tries\n', rani, count)
need an explanation for this answer? contact us directly to get an explanation for this answer