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
how to make a scientific calculater ?
Mention four important string handling functions in c languages .
What is difference between && and & in c?
What are external variables in c?
Which function in C can be used to append a string to another string?
What is difference between union All statement and Union?
Hello. How to write a C program to check and display president party like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"
What is s or c?
What is a null pointer assignment error? What are bus errors, memory faults, and core dumps?
When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?
What language is lisp written in?
What’s a signal? Explain what do I use signals for?
Why double pointer is used in c?
Can a variable be both constant and volatile?
Why use int main instead of void main?