+ 1

I need an explanation to this fragment of program (C)

/* Header(s) */ int main(void) { int item [100]; int a, b, c; int count; /* Some statement */ scanf("%d", & count); for(a=0; a<count; a++) scanf("%d", &item[a]); /* Need explanation from here */ for(a=1; a<count; ++a) for(b=count-1; b>=a; ++b) { if(item[b-1] > item[b]) { t = item[b-1]; item[b-1] = item[b]; item[b] = t; } } return 0; }

8th Dec 2019, 4:06 PM
Samiul Nasif Tayem
Samiul Nasif Tayem - avatar
2 Respuestas
0
I think no one understands this program
8th Dec 2019, 4:30 PM
Samiul Nasif Tayem
Samiul Nasif Tayem - avatar
0
Take a pen and a paper, take the count according to your wish and create an array with the count length. Now from that for loop, try to write every thing step by step, all that shuffling of numbers that is taking place inside the array. You are trying to sort the numbers in ascending order I guess. Kindly write the working code on the code playground and share the link here so that it is easy for us to explain.
8th Dec 2019, 6:19 PM
Avinesh
Avinesh - avatar