0% found this document useful (0 votes)
55 views3 pages

Dsu - Practical No. - 04

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views3 pages

Dsu - Practical No. - 04

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Name: - Vijayvardhan Vivekanand Patil.

Roll No.: - 42
Batch: - S2
Date: - 16 – 11 – 2021

PRACTICAL NO.: - 04
Program to Sort an Array Using Bubble Sort.

Code: -
#include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
int i,j,n,a[20],temp;
printf("\n Enter The No. of Element in Array : \n");
scanf("%d", &n);
printf("\n Enter The Element in Array : \n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0; i<n;i++)
{
for(j=0;j<n-i;j++)
{
if (a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("Sorted array is \t");
for (i=0;i<n;i++)
{
printf("\t %d",a[i]);
}
getch();
}

You might also like