answersLogoWhite

0


Best Answer

import java.io.*;

public class descendingorder

{

public static void main(String args[]) throws IOException

{

BufferedReader in= new BufferedReader(new InputStreamReader(System.in));

int i,j,n,t;

int a[]=new int[20];

System.out.println("Enter the number of elements:");

n=Integer.parseInt(in.readLine());

System.out.println("Enter the elements of the array:");

for(i=0;i<n;i++)

{

a[i]=Integer.parseInt(in.readLine());

}

for(i=0;i<n;i++)

{

for(j=0;j<n;j++)

{

if(a[i]>a[j])

{

t=a[i];

a[i]=a[j];

a[j]=t;

]

}

}

System.out.println("The orderer lit...");

{

for(i=0;i<n;i++)

{

System.out.println(a[i]);

}

}

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

Write a program to input values into an array and sort the array in descending order. Size of array is 10.

An algorithm to sort a list in ascending order is given below:

for( i = 0 to n-2)

for(j=i+1 to n-1)

if(array[i] > array[j])

swap the values of array[i] and array[j]

ï‚· Array index starts from 0.

ï‚· n is the size of the array

ï‚· Swapping is interchanging the values of two variables. Search the internet for algorithm

to swap the values of two variables.

ï‚· This is bubble sort algorithm

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

01/* C program to arrange or sort the array in the Descending order */02#include<stdio.h>

03#include<conio.h>

04void main()

05{

06 int ar[100],j,n,i,tmp;

07

08 printf(" Enter the size of the array \t");

09 scanf("%d",&n);

10

11 printf("Now enter the elements in the array \t");

12 for(i=0;i<n;i++)

13 {

14 scanf("%d",&ar[i]);

15 }

16

17 printf("\n Array is - ");

18 for(i=0;i<n;i++)

19 {

20 printf("\t %d",ar[i]);

21 }

22

23 for(i=0;i<n;i++)

24 {

25 for(j=0;j<n-i;j++)

26 {

27 if(ar[j]<ar[j+1])

28 {

29 tmp=ar[j+1];

30 ar[j+1]=ar[j];

31 ar[j]=tmp;

32 }

33 }

34 }

35

36 printf("\n\n Array in the Descending order is - \n");

37 for(i=1;i<=n;i++)

38 {

39 printf("\t %d",ar[i]);

40 }

41 getch();

42}

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

You cannot arrange an array in two orders at the same time. To arrange them in ascending order, sort the elements using an appropriate sorting algorithm. To reverse the order, work inwards from both ends of the array, swapping the elements as you go.

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

#include

#include

int main(void)

{

int x; \\ This is the counter variable

int array_var[10]; \\ This is the array

for(x=0; x<10; x++) {

scanf("%d", &array_var[x]);

}

for(x=0; x<10; x++) {

printf("%d\n", array_var[x]);

}

getch();

return 0;

}

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Analyze the problem! Do it by your self for you to learn!

-Your computer programming professor

This answer is:
User Avatar

User Avatar

Anonymous

Lvl 1
3y ago

A

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program that will arrange the elements of a 10-integer array in ascending and descending order?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Which way is ascending and descending?

Ascending order is when numbers are arranged from the smallest to the largest. Descending order is when numbers are arranged from the largest to the smallest.


How do you arrange words in cline and examples?

its arranged by ascending and descending order.........


How do you sort data in a database?

To sort is to arrange a field(column) depending on whether you choose to have them from lowest to highest or from highest to lowest (ascending or descending)


Output for ascending order and descending order?

Example 7, 30, 11, 27, 9, 16,Ascending Order = 7, 9, 11, 16, 27, 30 ( You simply arrange the number from lowest to highest number )Descending Order = 30, 27, 16, 11, 9, 7 ( You simply arrange the number from highest to lowest number )


Draw a flowchart to arrange 3 numbers in ascending order?

draw a flow chart to arrange 3 numbers in ascending order


What is it called to arrange in order from greastest to least?

descending


To arrange data in a desired order?

# You can sort data in ascending order depending on the desired requirements # You can also sort data in descending order depending on the application package your using 2b hb 3b b h 3h


How do you arrange 4 numbers in ascending order without array?

addends


Step by step in finding the median of ungrouped data?

Steps:1.) Arrange the data either ascending or descending order of their values.2.) Determine the total number of observations, say n.3.) If the set of number is odd then the middle number will be the median. And if the set of number is even then mean of middle two numbers will be the median.a.) After that we'll be starting to discuss and give examples on how to find the median of ungrouped data.Example1:1.) Find the median of 12, 15, 10, 18, 8.2.) Arrange the data either ascending or descending order of their values.8, 10, 12, 15, 18(ascending)18, 15, 12, 10, 8(descending)3.) If the set of numbers is an odd integer, find the middle number in the set of numbers.From the above middle number 12 then 12 is the median.Example2:1.) Find the median of 23, 46, 18, 32, 65, 20.2.) Arrange the data either ascending or descending order of their values.18, 20, 23, 32, 46, 65(ascending)65, 46, 32, 23, 20, 18(descending)3.) If the set of numbers is an even integer, find the two middle numbers in the set of numbers.From the above we can say that there are two middle numbers23 and 32. So,Md = 23+32/2 = 27.5By: HuebosFb: Jupete02@yahoo.comTwitter: @kimjupetehuebos


In Microsoft Excel sorting can be used to arrange data in?

Things can be put alphabetical order, numerical Order, date order and so on. Things can be put in ascending or descending order. You can also say that it arranges data in columns, if you take another perspective on your question.


If you arrange all the one digit odd numbers in ascending order and then in descending order to form five digit numbers what digit occupies the same place value?

this question is not soluble.the information given reduces the no. of candidates from 9999 to 900 but cant get closer than that


What will be the program to arrange numbers stored in array in ascending order using pointers?

sorry