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
How do I copy files?
Explain what is the heap?
What are c header files?
What is wrong with this statement? Myname = 'robin';
What is character constants?
what is ur strangth & weekness
Was 2000 a leap year?
can anyone suggest some site name..where i can get some good data structure puzzles???
hi... can anyone help me to make a two-dimensinal arrays in finding the sum of two elements plzzz. thnx a lot...
How can I automatically locate a programs configuration files in the same directory as the executable?
What is define c?
In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?
What is scanf_s in c?
Why do we use main function?
What is a static variable in c?