closed by
428 views

1 Answer

Best answer
1 votes
1 votes
In your first program, you have done a silly mistake.

In that, you print the array after every pass. In the printing loop of an array, you have used "i" variable which is also used in your main for loop of bubble sort so after the first iteration of bubble sort i's value becomes 5 and because of that reason your main loop is terminated.

So whatever result you get in your first program is the only a result of bubble sort's first pass.
selected by

Related questions

1 votes
1 votes
1 answer
1
Na462 asked Jan 8, 2019
1,399 views
#include <stdio.h>main (){unsigned x = -10;int X = 20;if (X x) printf ("Hello");else{ printf ("%d",x); printf ("Jello"); }}
2 votes
2 votes
1 answer
3
Hrithik Vashishtha asked Jul 4, 2022
363 views
#include <stdio.h int main () { int i, j; int a [8] = {1, 2, 3, 4, 5, 6, 7, 8}; for(i = 0; i < 3; i++) { a[i] = a[i] + 1; i++; } i ; for (j = 7; j 4; j ) { int i = j/2; ...
2 votes
2 votes
2 answers
4
atulcse asked Jan 15, 2022
661 views
Consider the following programint find (int n) { int a = 1; for (i = 1; i < = n; i ++) for (j = 1; j < = i; j++) for (k = 1; k <= j, k++) a = a + 1; ...