How to write a C Program Sort in C Programming Language ?
Solution For C Program :
/*C Program Sort.*/
#include <stdio.h>
int main(){
int a[5] = {5, 4, 2, 3, 1};
// Sort: Sequence
// A position lined up
int i;
for( i = 0 ; i < 5 ; i++ ){
// Find the smallest number
int min = i; // I suppose the first individual minimum
int j;
for( j = i+1 ; j < 5 ; j++ ){
if( a[j] < a[min] ){
min = j;
}
}
// Exchange smallest number with me to wait (item i) of digital
/*
Swap: Exchange
int temp = a;
a = b;
b = temp;
*/
int temp = a[i];
a[i] = a[min];
a[min] = temp;
}
// Export
for( i = 0 ; i < 5 ; i++ ){
printf("%d\n", a[i]);
}
return 0;
}
Program related to C Programming Language :
- C Program Array Index Example
- C Program String - Alphabet Count Example
- C Program Character toupper() Example
- C Program Array Example: Average
- C Program Array Example: Reverse
- C Program if - while - for Example
- C Program Switch - Case Example
- C Program 0.1 + 0.2 != 0.3 Solved
- C Program if - else if - else Example
- C Program typedef Example
- C Program scanf & gets Example
- C Program Friend & Operator: Point2D Example
- C Program Friend & Operator: Vector Example
- C Program Recursion Example
- C Program File Input & Output Example
- C Program Structure Example-2
- C Program Structure Example
- C Program Pointer Example
- C Program Function Example
- C Program String Example
- C Program String Count Example
- C Program String Example
- C Program Character Example
- C Program Sort Example
- C Program sizeof & memcpy Example
- C Program Array Example
- C Program to Array
- C Program print fill zero & mod/div
- C Program Double, Float Equal
- C Program nested for
- C Program for
- C Program if
- C Program System
- C Program Operation
- C Program to printf & scanf
- Example C Program Cuda Malloc
- C Program Side Length
Learn More :
Sort
- Sort Three Numbers - program reads in three Integers and displays them in ascending order.
- C Program Shell Sort Using C Programming Language
- C Program Selection Sort Using C Programming Language
- C Program to Bubble Sort Using C Programming Language
- C Program Insertion Sort Using C Programming Language
- Heap Sort Using C Programming Language
- C Program To Sort An Array In Ascending And Descending Order
- C Program To Sort An Array Of Names In Alphabetical And Reverse Order
- C Program Sort Array By Segment
- C Program to sort an array using bubble sort
- C Program to merge and sort two arrays
- Un-sortiertes Array and Sortiertes Array
- matrix sort in C Program
- C program that receives 10 float numbers from the console and sort them in non-ascending order, and prints the result
- C Program to accept 5 names from user & store these names into an array. Sort these array elements in alphabetical order
- C Program to accept n numbers from user,store these numbers into an array & sort the number of an array
- C Program to Implement Quick Sort
- QuickVSInsertion Sorting C Program