Answer:
#include<iostream>
#include<conio.h>
using namespace std;
void mirrorarray(char a[5],int n);
main()
{
int n;
cout<<"enter the size of array"<<endl;
cin>>n;
char a[n], b[n],c[2*n];
for (int i=0;i<=4;i++)
{
cout<<"\\enter the characters in array";
cin>>a[i];
}
mirrorarray(a,n);
getch();
}
void mirrorarray(char a[5],int n)
{
char b[n],c[2*n];
int k=0;
for (int j=4; j>=0; j--)
{
b[j]=a[k];
k=k+1;
}
for (int k=0;k<=4;k++)
{
c[k]=a[k];
c[k+5]=b[k];
}
for (int l=0;l<=9;l++)
{
cout<<c[l];
}
}
Step-by-step explanation:
In this program, an array of variable length n is taken. A function (method) is named as mirrorarray is designed to reverse the order of array and combine it with original array to make its mirror.
All arrays are considered as character data type, to full fill the requirement of question that elements should be string or character as parameter. The original array and mirror array are combined together in the end and displayed on output.