DS2_7

//Insertion Sort //BCA Support //www.bcasupport.xyz #include <iostream.h> #include <conio.h> int num[10],temp,a,b,pass=0; void insert(); void main() { clrscr(); cout<<"\nEnter 10 numbers :\n"; for(a=0;a<10;a++) cin>>num[a]; insert(); cout<<"\nSorted list :\n"; for(a=0;a<10;a++) cout<<num[a]<<endl; getch(); } void insert() { for(a=0;a<10;a++) { for(b=0;b<pass;b++) { if(num[b]>num[pass]) { temp=num[pass]; num[pass]=num[b]; num[b]=temp; } } pass++; } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.