answersLogoWhite

0

Correct formatting available here - http://pastebin.com/m2e947939 #include // The numbers we want to sort, need at least two int sort_size = 5; int sort_array[5] = { 1, 5, 2, 4, 3 }; int main() { int sorted = 0; int x; while( sorted != 1 ) { for( x = 0, sorted = 1; x != ( sort_size - 1 ); x++ ) { if( sort_array[x] > sort_array[x + 1] ) { // We are not sorted sorted = 0; // Swap sort_array[x] ^= sort_array[x + 1]; sort_array[x + 1] ^= sort_array[x]; sort_array[x] ^= sort_array[x + 1]; } } } printf( "And the numbers are...\n" ); for( x = 0; x < sort_size; x++ ) { printf( "%d\n", sort_array[x] ); } return 0; }

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

Sorting numbers using user-defined functions in C programming?

Assume your numbers are into an array. Then write any user-defined function implementing any kind of sorting. I am giving example of bubble sort.void bubble(int a[],int n){int i,j,t;for(i=n-2;i>=0;i--){for(j=0;ja[j+1]){t=a[j];a[j]=a[j+1];a[j+1]=t;}}}}


Different types of sorting techniques in c language?

types of sorting in c language are: insertion sort selection sort bubble sort merge sort two way merge sort heap sort quick sort


What are the types of sorting in c?

Any type you want to write. C does not provide sorting routines natively; you have to either use a library routine or write something. Some library implementations are based on quicksort or heapsort but, again, that is not a C (or C++) thing - it is a run-time library thing.


Write a C plus plus function that print a triangle of stars?

Write a function that print a triangle of stars.


Can you write any c prigramme in c language witthout any function?

No. At minimum, you need to provide a main() function.


Where do we write main function in a c program?

Into the source program.


Sorting an array in PHP without using sort function?

plz as soon as possible give me the program for shorting an array in asscending order without using any sort function in c++


Write a c program for matrix addition using function?

#include&lt;


Write a c program for function with no arguments and no return values?

void mynullfunction () {;}


Bubble sorting in c plus plus?

bubble_sort (int N, int *A) { int i; swap = 1; while (swap) { swap = 0; for (i=0; i&lt;N-1; ++i) { if (A[i] &gt; A[i+1]) { swap = 1; A[i] ^= A[i+1]; A[i+1] ^= A[i]; A[i] ^= A[i+1]; } } } }


How do you write a programm in c plus plus without using function main?

I don't think its possible. Every C++ program must at least have the main function.


How do you write a program in C to convert capital letters into small letters?

Use the tolower() function in the C standard library.