Question: 1 . Create a user - defined function. There will not be any output arguments. There will be two input arguments filename and n (

1
.
Create a user
-
defined function. There will not be any output arguments. There will
be two input arguments filename and n
(
a number
)
.
a
.
All the code will be within the user
-
defined function. Make sure that the
name of your m
-
file matches the name of your function.
2
.
Create an empty array and assign it to a variable.
3
.
Create a for loop that uses the input argument n as the last value in the vector
expression.
a
.
The for loop should perform n iterations.
4
.
Within the for loop, populate the array from step
2
using user input.
a
.
Prompt the user to enter a number and assign the number to the next index
after the current final element.
b
.
Once the for loop ends the array created in step
2
should now have n
elements.
5
.
Use the pseudocode below to sort the array from step
2
.
Indentation is used to show
where statements end.
Given an array arr=[1,...,n]
for i1 to n
assignminldx the value i
for ji+1 to n
if the element of arr at index j is less than the element at index minldx reassign minldx the value j
if minldx is not equal to i
swap the element at index i and the element at index minldx
write the sorted array to the file opened in step
.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!