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
Who is the main contributor in designing the c language after dennis ritchie?
How macro execution is faster than function ?
Explain how do you use a pointer to a function?
write a program to print the consecutive repeated character from the given string... input string is : hhhhjkutskkkkkggggj output should be like this: hhhhkkkkkgggg anyone help me...
Differentiate between static and dynamic modeling.
what is a NULL Pointer? Whether it is same as an uninitialized pointer?
What does the message "automatic aggregate intialization is an ansi feature" mean?
What is a ternary operator in c?
Write a program to identify if a given binary tree is balanced or not.
Do pointers store the address of value or the actual value of a variable?
What is the difference between fread and fwrite function?
What is meant by type casting?
What happens if header file is included twice?
What is a shell structure examples?
Write a program to print "hello world" without using a semicolon?