- #1
george2625
- 3
- 0
please help me with a c code for the merge sort... and i am getting a segmentation fault in running this selection sort,,, please help...
#include <stdio.h>
int main( )
{
int arr[10];
int i,j,temp;
for ( i = 0 ; i<10 ; i++ )
{
printf("enter the numbers: \n");
scanf("%d \n", arr);
}
for ( i = 0 ; i <8 ; i++ )
{
for ( j = i + 1 ; j <9 ; j++ )
{
if ( arr > arr[j] )
{
temp = arr ;
arr = arr[j] ;
arr[j] = temp ;
}
}
}
for ( i = 0 ; i <10 ; i++ )
printf("the sorted array is: %d \n", &arr);
return 0;
}
#include <stdio.h>
int main( )
{
int arr[10];
int i,j,temp;
for ( i = 0 ; i<10 ; i++ )
{
printf("enter the numbers: \n");
scanf("%d \n", arr);
}
for ( i = 0 ; i <8 ; i++ )
{
for ( j = i + 1 ; j <9 ; j++ )
{
if ( arr > arr[j] )
{
temp = arr ;
arr = arr[j] ;
arr[j] = temp ;
}
}
}
for ( i = 0 ; i <10 ; i++ )
printf("the sorted array is: %d \n", &arr);
return 0;
}