Advertisement

 /* Write a program in C to print individual characters of string in reverse order. */

 

#include<stdio.h>

#include<string.h>

 

int main()

{

    char str[100];

    int i, len=0;

 

    printf("Enter a string:");

    fgets(str, sizeof(str), stdin);

 

    len = strlen(str);

   

    printf("The characters of the string in reverse are:");

    for(i=len; i>=0; i--)

    {

        printf("%c", str[i]);

    }

    return 0;

}


Output:

Enter a string: Computer Science

The characters of the string in reverse are:

ecneicS retupmoC

Back

Post a Comment

0 Comments