Computer Science, asked by twinkle1125, 1 year ago

Can anyone please give me bubble sort program in c++.

Answers

Answered by yim64718
4

#include<iostream>

using namespace std;

int main()

{

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

cout<<"Enter the size of array: ";

cin>>n;

cout<<"Enter the array elements: ";  

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

cin>>a[i];

for(i=1;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;

  }

}

cout<<"Array after bubble sort:";

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

cout<<" "<<a[i];

return 0;

}

brilliant kar  de na plzzzzz...



twinkle1125: i got it..
yim64718: what
twinkle1125: nothing
yim64718: where r u frm
twinkle1125: chhattisgarh..
yim64718: ohh both dur he
twinkle1125: kahan h??
yim64718: gujarat
twinkle1125: ooo
yim64718: which class u study
Similar questions