Question
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.
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
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.
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.
Related Questions
Write a C++ program to fill an array with 6 numbers, and then reverse the values of this array....
Write a full program that reads in an arbitrary sequence of integers from the standard input, and...
Write a program that reads an unspecified number of integers, determines how many positive and negat...