write a program to sort the elements in a given array in c
language
Answer Posted / rakesh kumar
#include<stdio.h>
#include<conio.h>
#define MAX 10
void main()
{
int list[MAX],i,j,temp;
printf("input a 10 numbers");
for(i=0;i<MAX;i++)
{
scanf("%d",&list[i]);
}
for(i=0;i<MAX;i++)
{
for(j=i+1;j<MAX-1;j++)
{
if(list[i]>list[j])
temp=list[j];
list[j]=list[i];
list[j]=temp;
}
}
printf("Sort the number assending order");
for(i=0;i<MAX;i++)
{
printf("%d",list[i]);
}
getch();
}
| Is This Answer Correct ? | 8 Yes | 9 No |
Post New Answer View All Answers
What is sizeof in c?
Write a code to remove duplicates in a string.
When c language was developed?
What is a newline escape sequence?
What are actual arguments?
the constant value in the case label is followed by a a) semicolon b) colon c) braces d) none of the above
What does printf does?
Explain what is the benefit of using const for declaring constants?
What is a buffer in c?
Is stack a keyword in c?
Tell me is null always defined as 0(zero)?
What is function prototype in c language?
Differentiate between new and malloc(), delete and free() ?
What is d scanf?
Is c high or low level?