Question

Prompt the user for a number between 1 and 20. integers. Fill up each slot of the array with a random number from 1 to 100. Then display the contents of the array on the screen. You must use a loop. 7. Create an array that holds this number of

Using Matlab

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

Code

clear all
clc
x= input("Enter the size of an array (between 1 to 20) ="); % promot input

arr = zeros(1,x); % initialize array

for i = 1:x
a = 1; % lower limit for value in array
b = 100; % upper limit to value in array
k=randi([a,b]); % generate random value between a to b
arr(i)=k; % allocate value to ith element in array
end
printf("Array =")
disp(arr)

Output

Enter the size of an array (between 1 to 20) =11
Array =   71   66   62   97   32   98   11   62   56   91    3

Add a comment
Know the answer?
Add Answer to:
Using Matlab Prompt the user for a number between 1 and 20. integers. Fill up each...
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