#include <stdio.h> int main() { int a[5]={30,10,-5,20,0},pass,i,temp,n=5; for(pass=0;pass<n-1;pass++){ for(i=0;i<n-1;i++){ printf("In \n"); if(a[i]>a[i+1]){ temp=a[i]; a[i]=a[i+1]; a[i+1]=temp; printf("shorted successfully\n"); } } } for(i=0;i<n;i++){ printf("%d ",a[i]); } return 0; }ALGORITHM
STEP 1:Read a[n]STEP 2:Repeat for pass=1 to n-1 step by oneRepeat for i=1 to n-1 step by oneif(a[i]>[i+a])thena[i]<-->a[i+1]end ifend for iend for passSTEP 3:Write [n];Output
HTML
Tech News
Ad
bubble shortbubble short algorithmC language tutorialshow to implement Bubble short program
Bubble short Program in C | how to implement Bubble short Algorithm
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment