Answers for "how to reverse the sentence in c"

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 "how to reverse the sentence in c"

Code answers related to "C"

Browse Popular Code Answers by Language