Answers for "write a program in c to reverse a string"

C
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: %s\n", str[0]);
    printf("Reverse word: %s\n", str[1]);
    return 0;
}
Posted by: Guest on July-08-2021

Code answers related to "write a program in c to reverse a string"

Code answers related to "C"

Browse Popular Code Answers by Language