@VishalChoudhary/

GhostwhiteShadyDrawing

C

No description

fork
loading
Files
  • main.c
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <stdio.h>

int main(void) {
  
  int myArray[100],i = 0,j = 0,elem_1,elem_2,x,y;
  int count = 0,comp= 0;

  while(i<=15){

    printf("Enter the element you want to add : ");
    scanf("%d",&myArray[i]);
    i++;
  }
  for(x = 0;x < 15;x++){
    for(j = 0;j<15;j++){
    
     elem_1 = myArray[j];
     elem_2 = myArray[j+1];
     comp += 1;

     if(elem_1 > elem_2){
       myArray[j] = elem_2;
        myArray[j+1] = elem_1;
        count +=1;
	
      for(y = 0;y < 15;y++){
		printf("%d ",myArray[y]);
	
}
printf("\n");
    }

  }

  }

  	for(y = 0;y < 15;y++){
		printf("%d ",myArray[y]);
	
}
		printf("swap count : %d \n",count);
  
}