C++ Program to Reverse All the Strings Stored in an Array

Here you will get C++ program to reverse all the strings stored in an array.

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

using namespace std;

int main()
{
	char a[3][50];
	int i,j,k,len;
	
	cout<<"Enter 3 strings:\n";
	
	for(i=0;i<3;i++)
	{
		gets(a[i]);
	}
	
	cout<<"\nThe list of orignal strings:\n" ;
	
	for(i=0;i<3;i++)
	{
		cout<<a[i]<<"\n";
	}
	
	cout<<"\nThe list of changed strings:\n";
	
	for(i=0;i<3;i++)
	{
		len=strlen(a[i]);
		for(j=0,k=len-1;k>=0;j++,k--)
		{
			cout<<a[i][k];
		}
		
		cout<<"\n";
	}

	return 0;
}

Output

Enter 3 strings:
how
are
you

The list of orignal strings:
how
are
you

The list of changed strings:
woh
era
uoy

2 thoughts on “C++ Program to Reverse All the Strings Stored in an Array”

Leave a Comment

Your email address will not be published. Required fields are marked *