Program to print individual characters of a string in reverse order.

Here, we have a basic program example to print the characters of a string in reverse order using different languages. This program is created in c language, c++, Java, and Python.

Code to print string characters in reverse order in C language

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

void main()
{
    char str[100];
    int len,i;
       printf("Input the string : ");
       fgets(str, sizeof str, stdin);
	   len=strlen(str);
	   printf("The characters of the string in reverse are : \n");
       for(i=len;i>=0;i--)
        {
          printf("%c  ", str[i]);
        }
    printf("\n");
}

Code to print string characters in reverse order in C++ language

#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
    char str[200], ch;
    int i, j, len;
    cout<<"Enter the String: ";
    cin>>str;
    len = strlen(str);

    cout<<"The characters of the string in reverse are : "<<endl;
    for(i=len;i>=0;i--)
        {
          cout<<" "<<str[i];
        }
    return 0;
}

Code to print string characters in reverse order in Python language

str = input("Enter the String : ")
count = len(str)
print("The characters of the string in reverse order are: ")
for i in range(count-1,-1,-1):
    print(" ",str[i])