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
C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions
What is a void * in c?
What is a buffer in c?
What does it mean when a pointer is used in an if statement?
What is page thrashing?
Explain setjmp()?
Explain #pragma statements.
What is the method to save data in stack data structure type?
Difference between exit() and _exit() function?
What is structure packing in c?
What is difference between && and & in c?
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }
How can you pass an array to a function by value?
develop algorithms to add polynomials (i) in one variable
Why are algorithms important in c program?