Last active
September 18, 2017 10:18
-
-
Save RianWardana/33b29d1cfc771c55e4d5e83b59d86d0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NURIAN S WARDANA | |
// Membalik isi array dengan temporary array | |
#include <stdio.h> | |
int main() { | |
char array[] = {'a','b','c','d','e','f','g','h','i','j',}; | |
int arrayLength = sizeof(array) / sizeof(char); | |
char array2[arrayLength]; | |
int n; | |
for(n = 0; n < arrayLength; n++) { | |
array2[arrayLength - 1 - n] = array[n]; | |
} | |
for(n = 0; n < arrayLength; n++) { | |
array[n] = array2[n]; | |
} | |
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