How to save values to an array?

Write a program that takes multiple values and you store the numbers in an array.?

  • Sort the array in ascending order based on the following ways: • Find the maximum number from the array of size n. • Swap the number with the last position (n) of the array. • Reduce your array size by 1 and then find the maximum again from (0 to n-1). • Swap the number with the n-1 position of the array • Continue until you have sorted the whole array.

  • Answer:

    for(int i=0;i<n-1;i++) { id=0; for(j=0;j<n-i;j++) if( a[id]<a[j])id=j; T=a[id]; a[id]=a[n-1-i]; a[n-1-i]=T; }

Naman J at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

It might be useful to state what language the program is written in.

ray_diator

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.