Reverse a string
function reverseString(str) {
return str.split('').reverse().join('');
}
reverseString('string'); // "gnirts"
Reverse a string
function reverseString(str) {
return str.split('').reverse().join('');
}
reverseString('string'); // "gnirts"
Write an Algorithm to reverse a string without using any built-in function.
#include <stdio.h>
int main() {
char str[100], temp;
int i, j = -1;
// Take string input from user.
printf("Enter string");
gets(str);
i = 0;
// count the length of a input string.
while(str[++j]!='\0');
j = j - 1;
/* Swap the positions of an element. */
while (i < j) {
temp = str[i];
str[i] = str[j];
str[j] = temp;
i++;
j--;
}
printf("Reverse of a input string is :%s", str);
return (0);
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us