The following code shows a C Program for Implementing Insertion Sort.
//C Program for Implementing Insertion Sort
#include <stdio.h>
void InsertionSort(int a1[], int Length)
{
int i, j, x;
for(i=1;i<Length;i++)
{
x = a1[i];
j = i - 1;
while((j>=0) && (a1[j]>x))
{
a1[j + 1] = a1[j];
j--;
}
a1[j + 1] = x;
}
}
int main()
{
int elements_count, i;
int myarray[] = { 4, 1, 9, -13, 90, 56, 81, 34, -2, -15, 60, 88 };
elements_count=sizeof(myarray)/sizeof(int);
printf("Array before sorting...");
for(i=0;i<elements_count;i++)
printf("%d ", myarray[i]);
InsertionSort(myarray, elements_count);
printf("\nArray after sorting...");
for(i=0;i<elements_count;i++)
printf("%d ", myarray[i]);
printf("\n");
return 0;
}
Output

Further Reading
50+ C Programming Interview Questions and Answers
C Program to Find Factorial of a Number
- AI
- Android
- Angular
- ASP.NET
- Augmented Reality
- AWS
- Bioinformatics
- Biometrics
- Blockchain
- Bootstrap
- C
- C#
- C++
- Cloud Computing
- Competitions
- Courses
- CSS
- Cyber Security
- Data Science
- Data Structures and Algorithms
- Data Visualization
- Datafication
- Deep Learning
- DevOps
- Digital Forensic
- Digital Trust
- Digital Twins
- Django
- Docker
- Dot Net Framework
- Drones
- Elasticsearch
- ES6
- Extended Reality
- Flutter and Dart
- Full Stack Development
- Git
- Go
- HTML
- Image Processing
- IoT
- IT
- Java
- JavaScript
- Kotlin
- Latex
- Machine Learning
- MEAN Stack
- MERN Stack
- Microservices
- MongoDB
- NodeJS
- PHP
- Power Bi
- Projects
- Python
- Quantum Computing
- React
- Robotics
- Rust
- Scratch 3.0
- Shell Script
- Smart City
- Software
- Solidity
- SQL
- SQLite
- Tecgnology
- Tkinter
- TypeScript
- VB.NET
- Virtual Reality
- Web Designing
- WebAssembly
- XML