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
What is the c language function prototype?
What are the 4 types of programming language?
What are local static variables?
What are the 5 types of inheritance in c ++?
What will the code below print when it is executed? int x = 3, y = 4; if (x = 4) y = 5; else y = 2; printf ("x=%d, y=%d ",x,y);
Why clrscr is used after variable declaration?
Can you apply link and association interchangeably?
in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures
What is getch c?
What are the string functions? List some string functions available in c.
What does it mean when a pointer is used in an if statement?
What is string length in c?
What are the preprocessor categories?
What are the differences between new and malloc in C?
i have to apply for the rbi for the post of officers. i need to know abt the entrance questions whether it may be aps or techinical....