#include<stdio.h>
int main()
{
int i,temp,j,k,a[20],b,c;
scanf("%d",&i);
for(j=0;j<i;j++)
scanf("%d",&a[j]);
for(k=0;k<=i-1;k++)
{
for(b=k+1;b<=i-1;b++)
{
if(a[b]<a[k])
{
temp=a[k];
a[k]=a[b];
a[b]=temp;
}
}
}
for(c=0;c<=i-1;c++)
printf("%d\n",a[c]);
return 0;
}
4 Likes
The error is with the array size…
What if first value entered is more than 20…
1 Like
statement missing…return the value
1 Like
dynamically allocate the memory to avoid this error…
1 Like
Yes the problem is with the size of the array , increase it and your solution would be fine .
6 Likes
Please mention the problem statement
It’s Bubble sort bro