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
Which is more efficient, a switch statement or an if else chain?
How do you redirect a standard stream?
How can I implement sets or arrays of bits?
Explain what is a static function?
List the difference between a 'copy constructor' and a 'assignment operator' in C?
Give me the code of in-order recursive and non-recursive.
Describe the order of precedence with regards to operators in C.
Why do we need arrays in c?
Explain Basic concepts of C language?
When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd
How do you sort filenames in a directory?
What is #include cctype?
When should volatile modifier be used?
What is the best way to store flag values in a program?
Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?