This preview shows page 1. Sign up to view the full content.
Unformatted text preview: times.
Int = randi(1000); % a random integer between 1 and Times
fprintf('%10.0f is integer number %.0f\n',Int,count)
end Note that we’re not doing just 20 numbers here, but a number determined by
Note that we’re also printing the number ‘order’ in the list as well.
Sample output on next page Engineering
Education enter the number of integers to generate: 11
47 is integer number 1
98 is integer number 2
824 is integer number 3
695 is integer number 4
318 is integer number 5
951 is integer number 6
35 is integer number 7
439 is integer number 8
382 is integer number 9
766 is integer number 10
796 is integer number 11 How can we determine the max and min values listed?
Could we average the numbers?
Add the necessary decision structure to the previous code to determine
Max and Min values. (on next slide)
Max = 0; %initializing the smallest Max
Big = input('enter the maximum integer to be generated: ');
Min = Big; %initializing the largest Min
Num = input('enter the number of integers to generate: ');
for count=1:1:Num % go through thi...
View Full Document
- Spring '06