Computer Science, asked by wanisaba598, 8 days ago

write a program for in arranging 10 number in increasing order​

Answers

Answered by sandipsagare8588
0

Answer:

Explanation:

C Program to arrange 10 numbers in ascending order

/*C Program to arrange 10 numbers in ascending order*/

#include<stdio.h>

#include<conio.h>

void main()

{

int i,j,temp,a[10];

clrscr();

printf(“Enter 10 integer numbers: \n”);

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

scanf(“%d”,&a[i]);

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

{

for(j=i+1;j<10;j++)

{

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

{

temp=a[j];

a[j]=a[i];

a[i]=temp;

}

}

}

printf(“\n\nThe 10 numbers sorted in ascending order are: \n”);

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

printf(“%d\t”,a[i]);

getch();

}

OUTPUT:

Enter 10 integer numbers:

2

9

7

4

3

6

8

1

5

10

The 7 numbers sorted in ascending order are:

1     2       3       4       5            6       7       8       9      10

Answered by hukam0685
0

Question: WAP to arrange 10 numbers in increasing order.

Solution:

C Program to arrange 10 numbers in ascending order:

__________________________________

#include <stdio.h>

#include <conio.h>

void main()

{

int ELE [10],i,j, TEMP;

printf("Enter 10 integer numbers:");

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

{

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

}

for(i=0;i<10-1;i++)

{

for(j=i+1;j<10;j++)

{

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

{

TEMP=ELE[i];

ELE [i]=ELE[j];

ELE[j]=TEMP;

}

}

}

printf("Elements are now in ascending order:");

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

printf("%d\n",ELE[i]);

getch();

}

________________________________

OUTPUT:

On execution of the program:

Enter 10 integer numbers:

12

5

18

23

45

67

6

9

16

22

Elements are now in ascending order:

5

6

9

12

16

18

22

23

45

67

Explanation:

In the loop;

12 >5

As, 12 is greater than 5, so it will put into TEMP, then swapping of 12 and 5 is performed.

Now, first element of array is 5

second is 12.

for second time,

12<18, no swapping is performed.

By this way, the loop continues until all the elements are not arranged in ascending order.

Learn more:

1) Write a program to calculate simple interest using a user defined function.

https://brainly.in/question/5900887

2) Write names of conditional control statements?

https://brainly.in/question/5900807

#SPJ3

Similar questions