Write a script that will generate one random integer, and will print whether the random integer is an even or an odd number. (Hint: an even number is divisible by 2, whereas an odd number is not; so check the remainder after dividing by 2.)
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:4| Question number:20.4
All Answers
total answers (1)
Ch4Ex20.m
% Generates a random integer and prints whether it is even %
or odd
ranInt = randi([1, 100]);
if rem(ranInt,2) == 0
fprintf('%d is even\n', ranInt)
else
fprintf('%d is odd\n', ranInt)
end
Global temperature changes have resulted in new patterns of storms in many parts of the world. Tracking wind speeds and a variety of categories of storms is important in understanding the ramifications of these temperature variations. Programs that work with storm data will use selection statements to determine the severity of storms and also to make decisions based on the data.
need an explanation for this answer? contact us directly to get an explanation for this answer