Ascending Desending order sorting (Bubble Sort) of 10 numbers

Ascending Desending order sorting (Bubble Sort)

fprintf('Enter 10 number:')
for i=1:10
    x(i)=input('\nEnter number:');
end
for i=1:10
    for j=i+1:10
    if x(i)>=x(j)
        c=x(i);
        x(i)=x(j);
        x(j)=c;
    end
    end
end
fprintf('\nAsending order:')
    x'
for i=1:10
    for j=i+1:10
    if x(i)<=x(j)
        c=x(i);
        x(i)=x(j);
        x(j)=c;
    end
    end
end
   fprintf('\nDesending order:')
    x'

Comments