Sorted element's in order's ascending order






Input:An array with Integer data
Output An array with sorted elements in order ascending order
Sample Input:5,4,3,2,1
Sample output:1,2,3,4,5
------------------------------------
-------------------------------------

//Sorting data from array data
-----------------------------------------
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a[100],n,i,j,temp;
    printf("Enter the upper value:\n");
    scanf("%d",&n);
    for(i=0;i<=n;i++)
    {

        printf("Enter the Sorting number:\n");
        scanf("%d",&a[i]);
    }
     for(i=0;i<=n;i++)
    {
        for(j=0;j<n;j++)
        {

            if(a[j]>a[j+1])
            {
            temp=a[j+1];
            a[j+1]=a[j];
            a[j]=temp;
            }

        }


    }

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

{
printf("The sorting number is:%d\n",a[i]);
}

    return 0;
}
(By:shahimtiyaj)
SHARE

Shah Imtiyaj

Try to know thyself

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

একটি মন্তব্য পোস্ট করুন