Ask Question

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".

+3
Answers (1)
  1. 9 April, 08:40
    0
    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

    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.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “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 ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers