Computer Science, asked by pallabimishra, 3 months ago

Write a program to input 20 characters into an array and print it.Then arrange them in descending order and print it.

Please do it soon.​

Answers

Answered by Anonymous
2

Answer:

1. Create an array of some certain size and define its elements in sorted fashion.

2. Now take an input from the users which you want to search for.

3. Take two variables pointing to the first and last index of the array (namely low and high)

4. Run start a while and run it until low equals high.

5. Now, take a mid of low and high value, check whether value at mid equals the user input.

6. In case it matches the user input, it means we found the number, after which we must break out from the loop.

7. And if user input is greater than value at mid, then low is assigned the value of mid. Similarly if user input is smaller than value at mid, then high is assigned the value of mid.

8. In this way, the region of finding the user input becomes half.

Similar questions