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
Why is c called c?
What is data type long in c?
What are the difference between a free-standing and a hosted environment?
Do character constants represent numerical values?
Write a program to print fibonacci series using recursion?
Differentiate between functions getch() and getche().
praagnovation
What is the code in while loop that returns the output of given code?
simple program of graphics and their output display
How do we declare variables in c?
What do you understand by normalization of pointers?
Is c object oriented?
Define macros.
How can I read and write comma-delimited text?
When should you not use a type cast?