Here you will get C++ program to switch every one of the strings put away in an array.

Program

#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

Leave a Comment

error: Alert: Content is protected!!