#include<stdio.h>

main()
{ 
int A[9]={6,3,1,5,7,4,2,8,9};
  int Temp, I, J, K;


  printf("sebelum \n");
  for(I=0; I<=9-1; I++) {  
    printf(" %d ", A[I]); 
  }


  for(K=0; K <= 9; K++)
  {   J = K; 
     for (I=K+1; I<=9-1; I++)
     { if (A[I] < A[J])
       J = I;            
     }
     Temp = A[J];
     A[J] = A[K];
     A[K] = Temp;       
  } 

 printf("\n");  
 printf("sesudah \n");   
   for (I=0; I<=9-1; I++) { 
     printf(" %d ", A[I]);
   }
}

Recommended Answers

looks like a simple array sort to me. If so the pseudo code is already well known and you just have to match it to the details of this implementation

Jump to Post

All 3 Replies

Ah the perils of undocumented code. God and the coder knew what it did, now only God knows.

Since this is what it is you know that pseudocode is not exact so the conversion can be rubbish and still be a conversion. No one said you should have the following: C CODE to PSEUDOCODE to C CODE = same function from the final code! (Never happens.)

We also have the classic undocumented code so GIGO will be the result.

That out of the way you can take it line by line and write something, anything!

  1. Include libraries for the target language.
  2. Begin the main function.
  3. Declare an integer array of 6,3,1,5,7,4,2,8,9.

Keep going and while it doesn't tell us what this code did, it is garbage code so GIGO.

looks like a simple array sort to me. If so the pseudo code is already well known and you just have to match it to the details of this implementation

Be a part of the DaniWeb community

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