Asked by pauline

A. Write a program which reads an array of up to 200 integers from input and then does all the following in order

1. searches the array for a specific integer given by the user and outputs its position in the array;

2. outputs the largest element in the array;

3. sorts the array and outputs it in order.

Answers

Answered by Steve
for i=1 to 100, read a(i)

read n
for i=1 to 100, {if a(i)==n, print i}

n = a(1)
for i=2 to 100, if a(i)>n, n=a(i)
print n

See whether you can use the above section to repeatedly find the smallest element and place it in the next position. That is, sort the array.
There are no AI answers yet. The ability to request AI answers is coming soon!

Related Questions