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
application attempts to perform an operation?
In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping
Why c is a mother language?
Is c call by value?
How can you check to see whether a symbol is defined?
Why c is faster than c++?
What do you understand by friend-functions? How are they used?
How can I do peek and poke in c?
What are the types of pointers?
can we have joblib in a proc ?
Is null a keyword in c?
how to capitalise first letter of each word in a given string?
Write the syntax and purpose of a switch statement in C.
pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)
What is Dynamic memory allocation in C? Name the dynamic allocation functions.