Write down the program to sort the array.

Answer Posted / rama krishna sidhartha

//code for ascending order
for(i=0;i<n-1;i++)
{
for(j=1+1;j<n;j++)
{
if(a[j] >a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}

//code for descending order
for(i=n-1;i>0;i--)
{
for(j=n;j>i+1;j--)
{
if(a[j]<a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}

Is This Answer Correct ?    7 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is structure in c explain with example?

634


Write a program to swap two numbers without using third variable in c?

616


write a program to copy the string using switch case?

2401


How can I change their mode to binary?

694


hi send me sample aptitude papers of cts?

1651






What is cohesion and coupling in c?

587


Can you explain the four storage classes in C?

642


Is using exit() the same as using return?

675


Which programming language is best for getting job 2020?

605


c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above

611


what is stack , heap ,code segment,and data segment

2217


Is c is a high level language?

618


What is d scanf?

592


Write a program to find factorial of a number using recursive function.

646


What are the types of pointers in c?

528