#include<stdio.h>
void bsort(int*y,int n){
int i,j,temp;
for(i=0;i<n-1;i++){
for(j=0;j<n-i-1;j++){
if(y[j]>y[j+1]){
temp=y[j];
y[j]=y[j+1];
y[j+1]=temp;
}
}
}
}
int main(){
int a[100],n,i;
printf("enter the number of elements");
scanf("%d",&n);
if(n<1 && n>100){
printf("invalid Input");
}
else{
for(i=0;i<n;i++){
printf("enter the %d element",i+1);
scanf("%d",&a[i]);
}
for(i=0;i<n;i++){
printf("%d\t",a[i]);
}
bsort(a,n);
printf("\n new array \n");
for(i=0;i<n;i++){
printf("%d\t",a[i]);
}
}
return 0;
}
0 Comments
If you have any problem in code write in comments!