In: Computer Science
In C++, write a program that will read up to 10 letters (characters) into an array and write the letters back to the screen in the reverse order. The program should prompt the user to input all values and can determine whether the input has ended by a punctuation mark such as ‘.’ (make sure that you’ll include meaningful and intuitive messages to the user).
For example, if the input is abcde, the output should be edcba. Include appropriate messaging (UI) to the user.
#include<iostream>
#include<conio.h>
using namespace std;
int main() {
int i,temp,j;
char array[10];
cout<<"Enter any 10 Characters in to an array:
\n";
// for loop to enter 10 Characters into an array
for(i=0;i<10;i++) {
cout<<"Enter Character "<<i+1<<" into Array:
";
cin>>array[i];// inserting Character into an array
}
// printing Character array
cout<<"\n\nEntered Char Array: ";
for(j=0;j<10;j++){
cout<<array[j];
}
// here array reversing goes
for(i=0,j=10-1;i<10/2;i++,j--)
{
temp=array[i];
array[i]=array[j];
array[j]=temp;
}
cout<<"\nArray after Reversing: ";
for(j=0;j<10;j++)
{
cout<<array[j];
}
return 0;
}