Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  bubble sort
Language: C/C++
Code:
#include <stdio.h>
int main()
{
int array[50],num,c,d,swap;
printf("enter the number of the element");
scanf("%d", &num);
for(c=0;c<num;c++)
scanf("%d", &array[num]);

for(c=0;c<num-1;c++)
{
for(d=0;d<num-c-1;d++)
{
if (array[d]>array[d+1])
{
swap=array[d];
array[d]=array[d+1];
array[d+1]=swap;
}
}
}
for(c=0;c<num;c++)
scanf("%d", &array[c]);
return(0);
}
Comments: