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 check whether a number is prime or not using c?
exit () is used to a) exit () terminates the execution of the program itself b) exit () terminates the execution of the loop c) exit () terminates the execution of the block d) none of the above
When should you not use a type cast?
How can I call a function with an argument list built up at run time?
What is the explanation for prototype function in c?
What is the difference between volatile and const volatile?
What is a protocol in c?
What is #include conio h?
how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12
What is a rvalue?
Dont ansi function prototypes render lint obsolete?
Describe dynamic data structure in c programming language?
What is malloc calloc and realloc in c?
Why enum is used in c?
Explain what is the purpose of "extern" keyword in a function declaration?