0% found this document useful (0 votes)
26 views2 pages

Practical No 6 Dsu

The document contains a C program that implements the Bubble Sort algorithm to sort an array of integers. It prompts the user to input the number of elements and the elements themselves, then sorts and displays the sorted array. The program includes standard input/output functions and uses a temporary variable for swapping elements during sorting.

Uploaded by

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

Practical No 6 Dsu

The document contains a C program that implements the Bubble Sort algorithm to sort an array of integers. It prompts the user to input the number of elements and the elements themselves, then sorts and displays the sorted array. The program includes standard input/output functions and uses a temporary variable for swapping elements during sorting.

Uploaded by

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

Practical No: 6

CODE:

#include<stdio.h>

#include<conio.h>

void main()

int a[50],n,pass,i,j,temp=0;

setbuf(stdout,NULL);

printf("Aditya Salgude");

printf("\nEnter the value of n:\n");

scanf("%d",&n);

printf("Enter n elements:\n");

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

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

for(pass=1;pass<=n-1;pass++)

for(j=0;j<n-pass;j++)

{ if(a[j]>a[j+1]) { temp=a[j+1]; a[j+1]=a[j]; a[j]=temp;

}}

printf("The sorted array after Bubble sort is:\n"); for(i=0;i<n;i++)

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

getch();
}

OUTPUT:

You might also like