59.8k views
1 vote
Create a program in Matlab that prints the numbers from 1-100.

For multiples of 3 print "Yee" for multiples of 5 print "Haw" for numbers which are multiples of 3 and 5 print "Yee-Haw".

User Lxx
by
4.6k points

2 Answers

2 votes

Answer:

yee yee

Step-by-step explanation:

E yee yeee yeeeeeee E

User CMedina
by
4.7k points
5 votes

Answer:

numbers = 1:1:100;

for num=numbers

remainder3 = rem(num,3);

remainder5 = rem(num,5);

if remainder3==0

disp("Yee")

else

if remainder3 == 0 && remainder5 == 0

disp ("Yee-Haw")

else

if remainder5==0

disp("Haw")

else

disp("Not a multiple of 5 or 4")

end

end

end

end

Step-by-step explanation:

  • Initialize the numbers variable from 1 to 100.
  • Loop through the all the numbers and find their remainders.
  • Check if a number is multiple of 5, 3 or both and display the message accordingly.
User Piotr Rogowski
by
4.3k points