Answers for "reverse string c"

2

reverse string efficient in cpp without using function

#include <iostream>
using namespace std;
int main()
{
    char str[] = "Reverseme";
    char reverse[50];
    int i=-1;
    int j=0;
         /*Count the length, until it each at the end of string.*/ 
          while(str[++i]!='');
           while(i>=0)
                    reverse[j++]=str[--i];
            reverse[j]='';
      cout<<"Reverse of  a string is"<< reverse;
      return 0;
}
Posted by: Guest on September-16-2020
28

reverse string in python

'hello world'[::-1]
'dlrow olleh'
Posted by: Guest on December-06-2019
0

how to reverse a string in c

#include <stdio.h>
#include <string.h>

int main()
{
    char str[2][100];
    printf("Type Text: ");

    scanf("%[^n]%*c", str[0]);
    int length = strlen(str[0]);
    int i, j;
    for (i = 0, j = length - 1; i < length; i++, j--)
    {
        str[1][i] = str[0][j];
    }
    printf("Original Word: %sn", str[0]);
    printf("Reverse word: %sn", str[1]);
    return 0;
}
Posted by: Guest on July-08-2021

Python Answers by Framework

Browse Popular Code Answers by Language