Breaking News
yeni film izle hd film seyret film izle

Program to Sort an Array element

#include<stdio.h>
#include<conio.h>

void sorting(int *x,int y);

void main()
{
  int a[5],b,c;
  clrscr();
  printf("Enter 5 numbers");
  for(b = 0; b < 5; b++)
  {
    scanf("%d",&a[b]);
  }
 sorting(a,5);
 getch();
}

void sorting(int *x,int y)
{
  int i,j,temp;
  for(i = 1; i <= y-1; i++)
  {
    for(j = 0; j < y-i; j++)
    {
      if(*(x+j) >*(x+j+1))
      {
        temp = *(x+j);
        *(x+j) = *(x+j+1);
        *(x+j+1) = temp;
      }
    }
  }
  for(i = 0; i < 5; i++) 
  {
    printf("\t%d",*(x+i));
  }
}

Output

Enter 5 numbers 	26  19  21  7  12
      7  12  19  21  26  	

Check Also

Program to Remove duplicate Element in an Array

Program to Remove duplicate Element in an Array C program to delete duplicate elements from …