Announcement:

This is just the beginning of this blog, please don't copy any of my posts.

Thursday, 24 October 2013

[C Program] To Implement Program for Bubble sort

//Program for Bubble sort

#include<stdio.h>
#include<conio.h>
//Main function
void main()
{
int i,a[10],n,j,temp;
clrscr();
printf("\nEnter the size of array:");
scanf("%d",&n);
printf("\n\nEnter the elements into array:");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\nEntered array:  ");
for(i=0;i<n;i++)
{
printf("%d\t",a[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(a[j]>a[i])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("\n\nSorted list:    ");
for(i=0;i<n;i++)
{
printf("%d\t",a[i]);
}
getch();
}//end of main

/*Output

Enter the size of array:7

Enter the elements into array:12 88 5 100 32 77 50

Entered array:  12      88      5       100     32      77      50

Sorted list:    5       12      32      50      77      88      100 */
Share it Please

Pankaj Gaikar

Pankaj Gaikar is a professional blogger from Pune, India who writes on Technology, Android, Gadgets, social media and latest tech updates at Punk Tech , Being Android & Shake The Tech . Email me HERE

1 comments :

  1. Bet365 casino site | Review of the best online casinos in
    Bet365 Casino luckyclub is a very popular and widely available online casino, which is a top online gambling site. They have a large selection of slots,

    ReplyDelete

Copyright @ 2013 Pune University Bachelor of Engineering . Designed by Pankaj Gaikar | Love for The Tricks Machine