reverse words in a string code example
Example 1: reverse words in a given string
function reverse (word) {
word = word.split('.').reverse().join('.')
return word
}
word = 'i.like.this.program.very.much'
word = 'pqr.mno'
console.log(reverse(word))
Example 2: code to reverse a string
#include <stdio.h>
#include <string.h>
int main()
{
char s[100];
printf("Enter a string to reverse\n");
gets(s);
strrev(s);
printf("Reverse of the string: %s\n", s);
return 0;
}