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

how can i access hard disk address(physical address)? are we access hard disk by using far,near or huge pointer? if yes then please explain.....

1549


What should malloc(0) do?

781


Can we increase size of array in c?

683


How do we print only part of a string in c?

777


How can type-insensitive macros be created?

880






Explain what does a function declared as pascal do differently?

879


What do you mean by a sequential access file?

781


Explain what happens if you free a pointer twice?

774


Is main an identifier in c?

812


Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

887


List some of the dynamic data structures in C?

979


printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions

810


Are there namespaces in c?

746


What is volatile keyword in c?

748


write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.

3697