here i have two bubble sort versions.

void bsort()
{
        int i,j,jc=0,ic=0,temp,swap=1;

       //for(i=0;i<NOE & swap;i++){ this one or
        for(i=0;i<NOE-1 & swap;i++){ \\ this 
        swap=0,ic++;
         for(j=0;j<NOE-1-i;j++){
                jc++;
                if(a[j]>a[j+1]){
                        temp = a[j];
                        a[j] = a[j+1];
                        a[j+1] = temp;
                        swap = 1;
                        }
                }
        }
printf("jc=%d ic=%d\n",jc,ic);
}

i checked it .

in first case it only repeats one extra time which is not nedded .
other than that is there any situation where we get different results with different stataments.
Thanks,

here i have two bubble sort versions.

//for(i=0;i<NOE & swap;i++){ this one or

I think there will be one more "&" in line no. 6. But it won't help improving the performance though.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.