Question

In: Computer Science

In C++, write a program that will read up to 10 letters (characters) into an array...

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.

Solutions

Expert Solution

#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;
}


Related Solutions

In C++, Create an array of 10 characters. Use a loop to prompt for 10 letters...
In C++, Create an array of 10 characters. Use a loop to prompt for 10 letters (a-z|A-Z) and store each in the array. If an invalid character is entered, re-prompt until a valid char is entered. After 10 characters are stored in the array, use a loop to print out all characters in the array from the first to the last element. Then, use another loop starting at the last element to print all characters in the array in reverse...
write a program in C Write a function that is passed an array of characters containing...
write a program in C Write a function that is passed an array of characters containing letter grades of A, B, C, D, and F, and returns the total number of occurrences of each letter grade. Your function should accept both lower and upper case grades, for example, both 'b' and 'B' should be bucketed into your running total for B grades. Any grade that is invalid should be bucketed as a grade of 'I' for Incomplete. You must use...
Write a C++ program to read characters from the keyboard until a '#' character is read....
Write a C++ program to read characters from the keyboard until a '#' character is read. Then the program will find and print the number of uppercase letters read from the keyboard.
Write a C++ program that makes a 10x10 array and picks random letters and displays in...
Write a C++ program that makes a 10x10 array and picks random letters and displays in different positions
write this program in C++ Write a program that prompts a user for three characters. The...
write this program in C++ Write a program that prompts a user for three characters. The program must make sure that the input is a number 10 - 100 inclusive. The program must re prompt the user until a correct input is entered. Finally output the largest and the lowest value. Example 1: Input : 10 Input : 20 Input : 30 The largest is 30. The lowest is 10. Example 2: Input : 100 Input : 50 Input :...
Write a program in c++ to do the following: 2. Create an array to hold up...
Write a program in c++ to do the following: 2. Create an array to hold up to 20 integers. 3. Create a data file or download attached text file (twenty_numbers.txt) that contains UP TO 20 integers. 4. Request the input and output file names from the user. Open the files being sure to check the file state. 5. Request from the user HOW MANY numbers to read from the data file, up to twenty. Request the number until the user...
Write a C program that allows users to enter three runners name (up to 20 characters)...
Write a C program that allows users to enter three runners name (up to 20 characters) and their runtime (2 decimals) (1) First and Last name (2) Running time for 100 m ex. 9.96 seconds your program should rank them in ascending order of their runtime. example: usian Bolt - 9.96 sec - First Place John doe - 9.99 sec - second Place Pete Urel -10.11 sec - third place BUT they fan tie for first place and no second...
Write a program that asks the user to enter an array of 8 characters then you...
Write a program that asks the user to enter an array of 8 characters then you have to check if characters ‘b’ or ‘a’ appears within the characters and replace them with ‘B’ or ‘A’. For example you enter “a m a l a a b d” The output should be “A m A l A A B d”
Need a c++ program to generate a random string of letters between 8 and 16 characters.
Need a c++ program to generate a random string of letters between 8 and 16 characters.
Program in C: Write a program in C that reorders the elements in an array in...
Program in C: Write a program in C that reorders the elements in an array in ascending order from least to greatest. The array is {1,4,3,2,6,5,9,8,7,10}. You must use a swap function and a main function in the code. (Hint: Use void swap and swap)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT