write a program to arrange the contents of a 1D array in
ascending order

Answer Posted / kameshav

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]);
}
printf("\nAscending Order\n");
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("%d\n",a[i]);
}
return 0;
}

Is This Answer Correct ?    23 Yes 19 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions

820


What does 4d mean in c?

1239


which is conditional construct a) if statement b) switch statement c) while/for d) goto

1001


Explain about the functions strcat() and strcmp()?

797


Why malloc is faster than calloc?

818


Can you explain what keyboard debouncing is, and where and why we us it? please give some examples

1946


What are bitwise shift operators in c programming?

840


Which programming language is best for getting job 2020?

796


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

873


What is ponter?

1032


what are the facialities provided by you after the selection of the student.

1944


Explain how does free() know explain how much memory to release?

790


Write a program to swap two numbers without using a temporary variable?

868


how to print the character with maximum occurence and print that number of occurence too in a string given ?

2255


What are the 32 keywords in c?

859