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
how we can make 3d venturing graphics on outer interface
What is the value of c?
Why is sizeof () an operator and not a function?
diff between exptected result and requirement?
what is ur strangth & weekness
what is the significance of static storage class specifier?
how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12
What are the basic data types associated with c?
How do you override a defined macro?
Explain do array subscripts always start with zero?
What is the difference between array and pointer?
Is that possible to store 32768 in an int data type variable?
Why is structure important for a child?
Explain the use of keyword 'register' with respect to variables.
Explain how can I read and write comma-delimited text?