write a program to arrange the contents of a 1D array in
ascending order
Answer Posted / rajeev
#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;i++)
{
for(j=0;j<(n-1)-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
getch();
}
| Is This Answer Correct ? | 10 Yes | 12 No |
Post New Answer View All Answers
Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?
What are the usage of pointer in c?
How can you find the day of the week given the date?
What does c in a circle mean?
What is the correct declaration of main?
What is advantage of pointer in c?
What is action and transformation in spark?
write an algorithm to display a square matrix.
Why is c called "mother" language?
What is header file in c?
Why c is a procedural language?
Is anything faster than c?
if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.
printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions
What is the difference between array_name and &array_name?