Selection shorting in c Programming
BM Balmiki Mandal 20 Sep 2022 3 views 0 comments C Programming

Selection shorting in c Programming

How to Implement Selection Sort in C Programming

Selection sort is a simple sorting algorithm that works by repeatedly finding the minimum element from the unsorted part of the array and putting it at the beginning of the sorted part of the array.

How you can implement selection sort in C programming:

Selection shorting in c Programming

#include<stdio.h>
void main()
{
    int a[5],i,j,t,ele;
    ele=sizeof(a)/sizeof(a[0]);
    printf("Enter the array elements:");
    for(i=0;i<ele;i++)
    scanf("%d",&a[i]);
    printf("Unshorted Elements:");
    for(i=0;i<ele;i++)
    printf(" %d",a[i]);
    printf("\n");
    for(i=0;i<ele;i++)
    {
        for(j=i+1;j<ele;j++)
        {
            if(a[i]>a[j])
            {
                t=a[i];
                a[i]=a[j];
                a[j]=t;
            }
        }
    }
    printf("shorted Elements:");
    for(i=0;i<ele;i++)
    printf(" %d",a[i]);
    printf("\n");
}

Output:

Enter the array elements: 5 15 1 25 12
Unsorted Elements:  5 15 1 25 12
shorted Elements:  1 5 12 15 25

Further Reading:

Bubble shorting in c programming

Bubble short in string in c

Write a c program to short 2D array using bubble short

Selection shorting in c Programming

Enroll Now:

[ C-Programming From Scratch to Advanced 2023-2024] "Start Supercharging Your Productivity!"

Contact Us:

  • For any inquiries, please email us at [info@electro4u.net].
  • Follow us on insta  [ electro4u_offical_ ] for updates and tips.

 

Note: If you encounter any issues or specific errors when running this program, please let me know and I'll be happy to help debug them!

0 Comments

No comments yet, Be the first to comment.

Post a Comment

Please sign in to post a comment.

Related Posts

Bit wise operators Assignment

Bitwise Operators practical assignment: Take runtime input, bit-level manipulation, and different data units r...

AG Anvesh G 27 Sep 2026
Understanding Float and Double Binary Representation in C

Understanding Float and Double Binary Representation in CIntroduction:When we store decimal numbers such as 10...

AG Anvesh G 31 May 2026
Topic-wise C Programming Interview Questions

C Programming Interview Questions – Topic Wise1. IntroductionC programming is one of the most important langu...

AG Anvesh G 30 May 2026