Skip to content

Instantly share code, notes, and snippets.

@RianWardana
Created September 18, 2017 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RianWardana/f52f3af67e2ab31daefaa6296d432a50 to your computer and use it in GitHub Desktop.
Save RianWardana/f52f3af67e2ab31daefaa6296d432a50 to your computer and use it in GitHub Desktop.
// NURIAN S WARDANA
// Membalik isi array dengan temporary variable
#include <stdio.h>
int main() {
char array[] = {'a','b','c','d','e','f','g','h','i','j',};
int arrayLength = sizeof(array) / sizeof(char);
int lastIndex = arrayLength - 1;
char temp;
int n;
for(n = 0; n < arrayLength/2; n++) {
temp = array[n];
array[n] = array[lastIndex - n];
array[lastIndex - n] = temp;
}
for(n = 0; n < arrayLength; n++) {
printf("%c", array[n]);
if (n < arrayLength-1) printf(", ");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment