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


Please Help Members By Posting Answers For Below Questions

How do I copy files?

814


Explain what is the heap?

814


What are c header files?

785


What is wrong with this statement? Myname = 'robin';

1063


What is character constants?

908


what is ur strangth & weekness

2041


Was 2000 a leap year?

837


can anyone suggest some site name..where i can get some good data structure puzzles???

1854


hi... can anyone help me to make a two-dimensinal arrays in finding the sum of two elements plzzz. thnx a lot...

1703


How can I automatically locate a programs configuration files in the same directory as the executable?

869


What is define c?

772


In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?

993


What is scanf_s in c?

852


Why do we use main function?

910


What is a static variable in c?

873