Monday, August 31, 2020

Write a Program Simple Soring in C.

Simple Soring in C


  • Sorting all the data of a data structure in a systematic order is called sorting. These are of two types, in ascending order or descending order. 
  • The lowest value in ascending order is the store at the beginning of the Data List and the highest value at the end of the Data List, while the descending order has the opposite action. 
  • That is, the data of the highest value is the first and the data of the lowest value is the next store in the list.

EXAMPLE :-


#include <stdio.h>
int main()
{
int num[5], i ,j ,temp;
for (i = 0; i < 5; i++)
{
printf("Enter the Number :: %d : ", (i+1));
scanf("%d", &num[i]);
}
for (i = 0; i < 5; ++i)
{
for (j = i + 1; j < 5; ++j)
{
if (num[i] > num[j])
{
temp = num[i];
num[i] = num[j];
num[j] = temp;
}
}
}
printf("Sorting Order Array : \n");
printf("****************************\n");
for (i = 0; i < 5; ++i)
printf("%d\n", num[i]);
return 0;
}


OUTPUT


Enter the Number :: 1 : 90 Enter the Number :: 2 : 85 Enter the Number :: 3 : 45 Enter the Number :: 4 : 25 Enter the Number :: 5 : 77 Sorting Order Array : **************************** 25 45 77 85 90






No comments:

Post a Comment

Please do not any spam link in Comment Box