#include <stdio.h> #include <conio.h> struct node{ int number; struct node *next; }; struct node *head = NULL; /* insert a node directly at the right place in the linked list */ void insert_node(int value); int main(void){ struct node *current = NULL; struct node *next = NULL; int test[] = {8, 3, 2, 6, 1, 5, 4, 7, 9, 0}; int i = 0; /* insert some numbers into the linked list */ for(i = 0; i < i =" 0;">next != NULL){ printf("%4d\t%4d\n", test[i++], head->number); head = head->next; } /* free the list */ for(current = head; current != NULL; current = next) next = current->next, free(current); return 0; } void insert_node(int value) { struct node *temp = NULL; struct node *one = NULL; struct node *two = NULL; if(head == NULL) { head = (struct node *)malloc(sizeof(struct node *)); head->next = NULL; } one = head; two = head->next; temp = (struct node *)malloc(sizeof(struct node *)); temp->number = value; while(two != NULL && temp->number <>number) { one = one->next; wo = two->next; } one->next = temp; temp->next = two; }

Wednesday

## Insertion Sort C code | C Program Examples

Subscribe to:
Post Comments (Atom)

## List of C and C++ Programs

- Biggest of 3 Numbers Using Ternary Operator in C
- Binary Search C Program
- C program for Bubble Sort | C Program Examples
- C Program to Add the Given Two Matrices
- C Program to Calculate Matrix Multiplication
- C Program to Check the Given Character is Vowel or not
- C Program to Enter and Printing Values in a Matrix
- C Program to Enter and Printing Values in a Matrix
- C Program to Enter and Printing Values in a Matrix
- C Program to Find Even Numbers up to a Limit using IF-Else
- C Program to Find LCM and GCD of Two Numbers
- C Program to Find Odd Numbers up to a Limit using IF-Else
- C Program to Find Power of a Number using pow() Function
- C Program to Find Power of a Number x^n
- C Program to Find Sum of All Elements of Matrix
- C Program to Find the Sum of Lower Triangular Matrix Elements
- C Program to Find the Sum of Upper Triangular Matrix Elements
- C Program to Find Transpose of a Matrix
- C Program to Find Whether a Given Matrix is Unit Matrix or Not
- C Program to Generate Armstrong Numbers up to Limit n
- C Program to Generate Armstrong Numbers up to Limit n
- C Program to Generate Armstrong Numbers up to Limit n
- C Program to Generate Magic Square
- C Program to Generate Odd and Even Numbers up to a Limit n
- C Program to Generate Prime Numbers up to a Limit n
- C Program to Print Alphabets with ASCII Values
- C Program to Print Alphabets with ASCII Values
- C Program to Print Alphabets with ASCII Values
- Check Whether the Given no. is Prime or Not using C
- Checking a Number is Perfect Square or Not using C
- Checking the Given Number is Armstrong or Not uisng C
- Convert Binary Number to Decimal Number in C
- Convert Decimal Number to Binary Number in C
- Find Sum of +VE & -VE Elements in an Array in C
- Finding Roots of Quadratic Equation in C
- Finding the Number of 500, 100, 50, 20, 10, 5, 2, 1 Rupee Notes in a Given Amount
- How to swap two numbers using only two variables in C
- How to swap two numbers using three variables in C
- Insertion Sort C code | C Program Examples
- Performing Arithmetic Operations using Switch-Case
- Program for Printing Addition Table of the Given Number in C
- Program for Reversing an Integer in C
- Program of Simple Arithmetic Operation in C
- Program to Calculate the Cosine Series in C
- Program to Calculate the Exponential Series in C
- Program to Calculate the Sine Series in C
- Program to Change an Integer to Words in C
- Program to Check Whether the Person is Eligible to Vote or Not in C
- Program to Check Whether the Person is in Teen Age or Not in C
- Program to Convert Fahrenheit to Centigrade in C
- Program to Convert Numbers to Characters in C
- Program to Convert Temperature in Centigrade to Fahrenheit using C
- Program to count number of digits in an integer
- Program to count number of digits in an integer
- Program to Display Negative Elements of the Array in C
- Program to Display Positive Elements of the Array in C
- Program to Find Combination NCR Value in C
- Program to Find Fibonacci Series in C
- Program to Find Length of String in C
- Program to Find Sum of Digits of Integer
- Program to Find Sum of Digits of Integer in C
- Program to Find the Average of First n Natural Numbers
- Program to Find the Average of First n Natural Numbers
- Program to Find the Biggest of 3 Numbers Using if else in C
- Program to Find the Day of the Given Date in C
- Program to Find the Factorial of a Number in C
- Program to Find the Given Number is Perfect Number or not in C
- Program to Find the Sum of Fibonacci Series in C
- Program to Find the Sum of Odd and Even Numbers using Single For Loop in C
- Program to Find the Sum of Odd and Even Numbers using Two For Loops in C
- Program to Find Whether a Given Number is Even or Odd in C
- Program to Generate Floyd's Triangle in C
- Program to Generate Pascal's Triangle in C
- Program to Generate Permutation of String in C
- Program to Generate Trigonometric Table in C
- Program to Print All Divisors of a Given Number
- Program to Print all the Divisors of a Given Number
- Program to Print Multiples of a Given Number
- Program to Print Multiples of a Given Number
- Program to Print the Multiplication Table
- Program to Print the Multiplication Table in C
- Program to Read and Reverse an Array in C
- Simultaneous Equation using Gauss Elimination Method in C
- Why use break statement inside switch case in C