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
Write a program to generate the Fibinocci Series
Explain what is the purpose of "extern" keyword in a function declaration?
What is the use of define in c?
Is c still relevant?
how can use subset in c program and give more example
Explain what are the different data types in c?
while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above
How to get string length of given string in c?
Function which gives a pointer to a binary trees const an integer value at each code, return function of all the nodes in binary tree.?
What is meant by operator precedence?
Can a pointer be volatile in c?
How is = symbol different from == symbol in c programming?
How the c program is executed?
Can you write a programmer for FACTORIAL using recursion?
What is array of structure in c programming?