write a program to arrange the contents of a 1D array in
ascending order
Answer Posted / prakashmca
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],n,i,j,temp;
clrscr();
printf("\n enter the size of the array");
scanf("%d",&n);
printf("\n enter the contents of the array");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n-1;i++)
{
for(j=0;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
getch();
}
| Is This Answer Correct ? | 7 Yes | 14 No |
Post New Answer View All Answers
Which of these functions is safer to use : fgets(), gets()? Why?
Explain what does the function toupper() do?
why do some people write if(0 == x) instead of if(x == 0)?
Hai what is the different types of versions and their differences
How can I access an I o board directly?
What is the use of static variable in c?
What does printf does?
What are different types of variables in c?
Can variables be declared anywhere in c?
What is boolean in c?
What is formal argument?
Is c++ based on c?
How to find a missed value, if you want to store 100 values in a 99 sized array?
Explain how do you generate random numbers in c?
What is the auto keyword good for?