Skip to content

Commit

Permalink
updated challenge YearOfProgramming#1
Browse files Browse the repository at this point in the history
  • Loading branch information
almyk committed Jan 3, 2017
1 parent 52ef65c commit bf0b99c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions challenge_1/c/almyk/src/challenge1.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@

int main(void){
char chArr[100];
char temp;
int n;

printf("Enter string you want to see reversed: ");
scanf("%99[^\n]", chArr);

n = strlen(chArr);
for(int i=n-1; i>=0; i--) printf("%c", chArr[i]);
printf("\n");
for(int i=0; i< n/2; i++){
temp = chArr[i];
chArr[i] = chArr[n - i - 1];
chArr[n - i - 1] = temp;
}
printf("Reversed String: %s\n", chArr);

return 0;
}

0 comments on commit bf0b99c

Please sign in to comment.