Write c++ program to print revirse string.


Write a program to display string from backward.
Write c++ program to print revirse string.
Print reverse string using c++ code.

 
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
 
int main( )
{
        clrscr( );
        char str[80];
        cout<<"Enter a string:";
        gets(str);
 
        for(int l=0; str[l]!='\0';l++);//Loop to find the length of the string
 
        for(int i=l-1;i>=0;i--)//Loop to display the string backwards
               cout<<str[i];
 
        getch();
        return 0;
}

No comments:

Post a Comment