Home TechnologyProgramming Subscribe to RSS

I Have To Write A Program Of Sorting Of Arrays. Can Any One Help?

Write a program that takes input from user and store in an array of size 10 and arrange them in ascending order.

Answer Question

1 Answer - Sort by: Date | Rating

    Void Main( )
    {
    Int a,b,k,j,I, temp, min;
    Array x[10];
    For (int a = 0; a<10; a++)
    {// Enter 10 numbers one by one in an array

    printf("Enter no. Of elements in the list:- ");
    scanf ("%d",&b);

    //storing numbers in an array
    x[a]=b;

    }

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

    {
    // assuming that the first number is smaller

    min=x[i];
    k=i;

    for (j=(i+1);j<10;j++)
    {
    // Checking the next number is smaller of not

    if (a[j]
    {
    //storing the smaller number in the int min

    min=a[j];
    k=j;
    }
    // swap current element with next element in the array
    // if the current element is greater

    temp=a[k];
    a[k]=a[i];
    a[i]=temp;

    }
    }
    0 0

    Ellie82 

    answered 1 year ago

      More

      More

         
         

        Ask a Question via Twitter

        Send a question to @askblurtit and we will publish it online and send you a reply everytime you receive an answer.

        Blurtit Store

        Get T-shirts, hoodies, caps and more at the Blurtit store

        Blurtit International