Tuesday, 22 March 2016

Write A C++ Program To Display String From Backward

#include<iostream>
using namespace std;

int main( )
{
    char str[80];
int l;
    cout<<"Enter string: ";
    cin.getline(str, 80);
 
    for(l = 0; str[l] != '\0'; l++);
    for(int i = l - 1; i >= 0; i--)
    {
        cout << str[i];
    }

    return 0;
}

Output:-

www.programmingwithbasics.com

No comments:
Write comments

Recommended Posts × +