Hi,
I have written code to sort array numbers in increasing order
Code:
#include <stdio.h>
int main()
{
int i = 0;
int j = 0;
int temp;
int array[5] = { 50, 40, 30, 20, 10};
for ( i = 0; i < 5; i++)
{
for ( j = i + 1; j < 5; j++)
{
temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
for ( i = 0; i < 5; i++)
{
printf(" %d ", array[i]);
}
return 0;
}
I am now trying to make a function to sort array in increasing order
Code:
#include <stdio.h>
void foo ( int *ptr)
{
// How to sort array in increasing order in function
}
int main()
{
int i = 0;
int j = 0;
int temp;
int array[5] = { 50, 40, 30, 20, 10};
foo(&array[0]);
// print array after calling function
for ( i = 0; i < 5; i++)
{
printf(" %d ", array[i]);
}
return 0;
}
I am looking help to make function so how to make function that sort array in increasing order