Ask Question - Get Answer

1 Ans Write a C program to implement Insertion sort data structure and algorithm

Asked by AL MaMun (4 Golds) Friday, 31 Jul 2020, 06:49 AM at (Education Tutorials)

Please log in to answer, like and save
0
Save 0

<<< Previous
Log in to Answer Next >>>

Answer(s):

Insertion sort C program :


#include<stdio.h>

int main()

{

    int a[100], i, j, k, n;

    scanf("%d", &n);

    for(i=0; i<n; i++)

        scanf("%d", &a[i]);

    for(i=0; i<n; i++)

        printf("%d ", a[i]);

    printf("\n\n");


    for(j=1; j<n; j++)

    {

        for(i=0; i<n; i++)

        {

            k = a[i];

            if(a[i]>a[j])

            {

                a[i]=a[j];

                a[j]=k;

            }

        }

    }

    for(i=0; i<n; i++)

        printf("%d ", a[i]);

}


Answered by AL MaMun (4 Golds) Friday, 31 Jul 2020, 06:50 AM

Please log in to Upvote, Downvote and Report
           

Related Q/A:

1 Ans A Quest for Peace in the Middle East: Recent Perspectives - composition

1 Ans 41st BCS Technical Subjective Written Exam Question Download

1 Ans How to Learn HTML - HyperText Markup Language easily? 

1 Ans Write a C program to print Floyd Triangle

1 Ans Write a C program to print Fibonacci number using recursion

2 Ans Train Location Message TR Train_Code and Send to 16318 Example: TR 705 Send to 16318

3 Ans BPSC Assistant Programmer Lab Aptitude test Programs and Queries with Proper solution (Taken By BCC)

1 Ans Write a C program to find nth Fibonacci number

2 Ans Write a C program for Binary Search algorithm

1 Ans Write a C program for Interest Calculation


AL MaMun (active on Monday, 06 Sep 2021, 11:15 AM) (4 Golds)
Birds of the sky (active on Wednesday, 27 Apr 2022, 12:16 PM) (2 Golds)
Tajrimun Elisha (active on Friday, 22 Nov 2019, 08:56 AM) (2 Golds)
Hena Begum (active on Friday, 15 Feb 2019, 11:04 PM) (8 Bronzes)
Ghost (active on Saturday, 05 Jan 2019, 10:37 AM) (1 Silver)
BrandonDug (active on Thursday, 17 Dec 2020, 05:25 AM) ( New Contributor )
APU KUMAR ROY (active on Sunday, 22 Sep 2019, 02:42 AM) (1 Bronze)
Md Hasan (active on Saturday, 02 Nov 2019, 10:02 AM) (4 Bronzes)
student (active on Monday, 27 Jul 2020, 07:28 PM) (2 Bronzes)
GoMedii (active on Monday, 21 Dec 2020, 02:28 PM) ( New Contributor )
Shahansha Habib (active on Monday, 21 Oct 2019, 04:09 PM) (2 Bronzes)
عبد الحنان سلفي (active on Friday, 28 Aug 2020, 05:04 PM) (2 Bronzes)
Miskatul Zannat Bristy (active on Friday, 16 Jul 2021, 02:08 AM) ( New Contributor )
Jackson99 (active on Monday, 27 Apr 2020, 02:44 PM) ( New Contributor )
Md Mondol (active on Tuesday, 23 Jul 2019, 10:28 PM) (2 Bronzes)
Hazrat (active on Sunday, 26 May 2019, 05:55 AM) (2 Bronzes)
MD SAIFUL ISLAM (active on Friday, 24 Jan 2020, 04:13 PM) ( New Contributor )
Daily Science (active on Friday, 03 Jan 2020, 07:52 PM) ( New Contributor )
Sowrov (active on Thursday, 14 Feb 2019, 10:48 AM) (7 Bronzes)
Abdul Halim (active on Thursday, 03 Oct 2019, 05:36 PM) ( New Contributor )
Show All Members

Online Now 1
Today's Unique PageViews 297
Today's Total PageViews 2317
Site's Total PageViews 3489263