Monday 10 February 2020

CPP program to print the reverse of a string

Source Code:

#include<iostream>
#include<string.h>
using namespace std;
int main()
{
char a[10];
int i;
cout<<"Enter a string: ";
cin.getline(a,10);
cout<<"The reversed name is: ";
for(i=10;i>=0;i--)
{
cout<<a[i];
}

return 0;
}


Program Output:

No comments:

Post a Comment