Question

MATLAB Write segment of code using nested for loops to print out the following pattern. Your...

MATLAB

Write segment of code using nested for loops to print out the following pattern. Your segments of code should prompt the user for a positive integer, n, and print the following star pattern depending on n.

An equilateral triangle. Pictured below is case n = 6.

*

* * *

* * * * *

* * * * * * *

* * * * * * * * *

* * * * * * * * * * *

0 0
Add a comment Improve this question Transcribed image text
Answer #1

n = input("Enter n: ");
for i=1:n
j = 2*i - 1;
for p=1:j
fprintf("* ")
end
fprintf("\n");

end

---------------------------------------------------------------------------------------------------

See Output





Thanks, PLEASE UPVOTE

Add a comment
Know the answer?
Add Answer to:
MATLAB Write segment of code using nested for loops to print out the following pattern. Your...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT