write a program to arrange the contents of a 1D array in
ascending order
Answer Posted / poornima
int main()
{
int a[20],n,i,j,temp;
printf("Enter the size of an array : ");
scanf("%d",&n);
printf("Enter the array elements : ");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=i;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[j];
a[j]=a[i];
a[i]=temp;
}
}
}
printf("\nAscending Order\n");
for(i=0;i<n;i++)
{
printf("%d\n",a[i]);
}
return 0;
}
Is This Answer Correct ? | 65 Yes | 22 No |
Post New Answer View All Answers
What is a rvalue?
How can you restore a redirected standard stream?
What does c in a circle mean?
How can I write a function that takes a format string and a variable number of arguments?
What are the advantages of c language?
difference between native and cross compilers
How can I change their mode to binary?
what is recursion in C
Why is c called c not d or e?
GIVEN A FLOATING POINT NUMBER HOW IS IT ACTUALLY STORED IN MEMORY ? CAN ANYONE EXPLAIN?? THE 32 BIT REPRESENTATION OF A FLOATING POINT NUMBER ALLOTS: 1 BIT-SIGN 8 BITS-EXPONENT 23 BITS-MANTISSA
Is c call by value?
What are the advantage of c language?
Explain why C language is procedural?
Is c is a procedural language?
Is null always defined as 0(zero)?