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
C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions
What does 4d mean in c?
which is conditional construct a) if statement b) switch statement c) while/for d) goto
Explain about the functions strcat() and strcmp()?
Why malloc is faster than calloc?
Can you explain what keyboard debouncing is, and where and why we us it? please give some examples
What are bitwise shift operators in c programming?
Which programming language is best for getting job 2020?
How can I automatically locate a programs configuration files in the same directory as the executable?
What is ponter?
what are the facialities provided by you after the selection of the student.
Explain how does free() know explain how much memory to release?
Write a program to swap two numbers without using a temporary variable?
how to print the character with maximum occurence and print that number of occurence too in a string given ?
What are the 32 keywords in c?