About Me

My photo
Vijayapur, Karnataka, India
I am interested in Teaching.

Monday, 19 June 2023

Bubble Sort

 /* C code for the implementation of Bubble Sort*/

#include<stdio.h>

int main()

{

int n, i, a[50], temp;

printf(“Enter n”);

scanf(“%d’,&n);                     

printf(“Enter %d values”,n);

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

{

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

}

/* Code for bubble sort begins*/

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

{

for(j=0;j<n-i-1;j++)

{

if(a[j]>a[j+1])

{

temp=a[j];

a[j]=a[j+1]

a[j+1]=temp;

}

}

}

printf(“\n Sorted Values are as follow\n”);

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

{

printf(“\n%d”,a[i]);

}

return(0);

}

No comments:

Quiz-1 for DCET 2025 (Introduction to Python)

 1. Introduction to Python https://docs.google.com/forms/d/e/1FAIpQLSc3LFrMaswLg6mltJ3NN5QGbALA9Uc53KWPp4oV5HN4SaM0Iw/viewform?usp=sharing...