CoolInterview.com - World's Largest Collection of Interview Questions
Start Your Own website Now
Sponsored Links

Interview Questions
Our Services

Get 9,000 Interview Questions & Answers in an eBook.


  • 9500+ Pages
  • 9000 Question & Answers
  • All Tech. Categories
  • 14 MB Content

    Get it now !!



    Send your Resume to 6000 Companies


  • INTERVIEW QUESTIONS C ARRAYS IN C DETAILS
    Question :
    How can you sort the elements of the array in descending order?
    Category Arrays in C Interview Questions
    Rating (0.7) By 164 users
    Added on 10/24/2004
    Views 3924
    Rate it!
    Answers:

    By calling Sort() and then Reverse() methods.



    By calling Sort() and then Reverse() methods



    Posted by: srihariraju    

    Contact srihariraju Contact srihariraju

    #include<stdio.h>
    main()
    {
    int a[10],sum=0;
    int i,j,temp;
    printf("enter the arraya");
    for(i=0;i<10;i++)
    {
    scanf("%d",&a[i]);
    //sum=sum+a[i];
    }
    for(i=10;i>=0;i--)
    {
    for(j=0;j<10;j++)
    {
    if(a[i]==a[j])
    printf("%d
    ",a[j]);
    }
    }
    }



    Posted by: Byka.swapna    

    Contact Byka.swapna Contact Byka.swapna

    #include<stdio.h>
    main()
    {
    int a[10],sum=0;
    int i,j,temp;
    printf("enter the arraya");
    for(i=0;i<10;i++)
    {
    scanf("%d",&a[i]);
    //sum=sum+a[i];
    }
    for(i=10;i>=0;i--)
    {
    for(j=0;j<10;j++)
    {
    if(a[i]==a[j])
    printf("%d ",a[j]);
    }
    }
    }



    Posted by: Ananda pani    

    Contact Ananda pani Contact Ananda pani

    #include<stdio.h>
    main()
    {
    int a[10],sum=0;
    int i,j,temp;
    printf("enter the arraya");
    for(i=0;i<10;i++)
    {
    scanf("%d",&a[i]);
    //sum=sum+a[i];
    }
    for(i=0;i<10;i--)
    {
    for(j=0;j<10;j++)
    {
    if(a[i]>a[j])
    printf("%d ",a[i]);
    }
    }
    }



    Posted by: Hemanth    

    Contact Hemanth Contact Hemanth

    By using any sorting algorithm. Use Quick sort which runs in logn time.



    Posted by: Avinash    

    Contact Avinash Contact Avinash

    #include<stdio.h>
    main()
    {
    int a[10],sum=0;
    int i,j,temp;
    printf("enter the arraya");
    for(i=0;i<10;i++)
    {
    scanf("%d",&a[i]);
    //sum=sum+a[i];
    }
    for(i=0;i<10;i--)
    {
    for(j=0;j<10;j++)
    {
    if(a[i]>a[j])
    printf("%d ",a[i]);
    }
    }
    }



    Posted by: Nirmal    

    Contact Nirmal Contact Nirmal

    #include<iostream>
    using namespace std;
    int main()
    {
    int arr[10],i,temp,j;
    //enter elements
    for(i=0;i<10;i++)
    {
    cin>>arr[i];
    }
    //sort in descending order
    for(i=0;i<10;i++)
    {
    for(j=i+1;j<10;j++)
    {
    if(arr[i]<arr[j])
    {temp=arr[j];
    arr[j]=arr[i];
    arr[i]=temp;}
    }
    }
    //display elements
    for(i=0;i<10;i++)
    {
    cout<<arr[i]<<" ";
    }
    system("pause");
    return 0;
    }



    Posted by: prachi    

    Contact prachi Contact prachi

    //a program to sort array in desc order
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    int a[10],i,j,temp=0;
    clrscr();
    printf("Enter the 10 elements");
    for(i=0;i<10;i++)
    scanf("%d",&a[i]);
    for(i=0;i<10;i++)
    {
    for(j=0;j<10;j++)
    {
    if(a[j]<a[i])
    {
    temp=a[j];
    a[j]=a[i];
    a[i]=temp;
    }}}
    for(i=0;i<10;i++)
    printf("%d ",a[i]);
    getch();
    }



    Posted by: shri kadian    

    Contact shri kadian Contact shri kadian

    If you have the better answer, then send it to us. We will display your answer after the approval.
    Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
  • Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification  Enter the above shown code:*
    Inform me about updated answers to this question

       
    Related Questions
    View Answer
    Array is an lvalue or not?
    View Answer
    Can the size of an array be declared at runtime?
    View Answer
    Can the sizeof operator be used to tell the size of an array passed to a function?
    View Answer
    Is it better to use a pointer to navigate an array of values,or is it better to use a subscripted array name?
    View Answer
    When does the compiler not implicitly generate the address of the first element of an array?
    View Answer


    Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

    View ALL Arrays in C Interview Questions

    User Options
    Sponsored Links


    Copyright ©2003-2014 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions

    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Dedicated Servers | C Interview Questions & Answers

    Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes


    Cache = 0.015625 Seconds