write a program to sort the elements in a given array in c
language
Answer Posted / rajesh evani
#include<stdio.h>
void main()
{
int a[5],t;
int i,j=0;
printf("enter 5 values into the array a");
for(i=0;i<5;i++)
{
scanf("%d",&a[i]);
}
printf("the sorted order of elements");
for(i=0;i<5;i++)
{
for (j=0;j<5;j++)
{
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
for(i=0;i<5;i++)
{
printf("%d",a[i]);
}
}
| Is This Answer Correct ? | 225 Yes | 62 No |
Post New Answer View All Answers
In which layer of the network datastructure format change is done
Explain how can I convert a string to a number?
Explain what is page thrashing?
How do you print only part of a string?
Write program to remove duplicate in an array?
What is the use of linkage in c language?
What the different types of arrays in c?
What is the use of c language in real life?
Write a c program to build a heap method using Pointer to function and pointer to structure ?
What is identifiers in c with examples?
Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create.
Why is c called c?
Explain the Difference between the New and Malloc keyword.
What are register variables? What are the advantage of using register variables?
Why is sizeof () an operator and not a function?