#include <stdio.h>
void main ()
{
int i,j,a,n,number[30];
printf (“Enter the value of N\n”);
scanf (“%d”, &n);
printf (“Enter the numbers \n”);
for (i=0; i<n; ++i)
scanf (“%d”,&number[i]);
for (i=0; i<n; ++i)
{
for (j=i+1; j<n; ++j)
{
if (number[i] > number[j])
{
a= number[i];
number[i] = number[j];
number[j] = a;
}
}
}
printf (“The numbers arranged in ascending order are given below\n”);
for (i=0; i<n; ++i)
printf (“%d\n”,number[i]);
} /* End of main() */
/*——————————————————————
Output
Enter the value of N
5
Enter the numbers
80
20
67
10
45
The numbers arranged in ascending order are given below
10
20
45
67
80
——————————————————————*/
Not Satisfied ? Just search & get the result
Related posts:
- C program to accept N numbers sorted in ascending order and to search for a given number using binary search. Report success or failure in the form of suitable messages
- C program to sort N numbers in ascending order array with suitable headings
- Sample – Program to enter 10 integers in a single-dimension array and then print out the array in ascending order.
- C program to accept a matrix of given order and interchange any two rows and columns in the original matrix
- C program to read in four integer numbers into an array and find the average of largest two of the given numbers without sorting the array. The program should output the given four numbers and the average with suitable headings.
