In this lab, you complete a partially written C++ program that includes built-in functions that convert characters stored in a character array to all uppercase or all lowercase. The program prompts the user to enter nine characters. For each character in the array, you call the built- in functions tolower() and toupper(). Both of these functions return a character with the character changed to uppercase or lowercase. Here is an example: char sample1 = 'A'; char sample 2a'; char result1, result2; result1 = tolower(sample1); result 2 = toupper(sample 2); The source code file provided for this lab includes the necessary variable declarations and the necessary input and output statements. Comments are included in the file to help you write the remainder of the program.

Respuesta :

Answer:

#include <iostream>

using namespace std;

int main()

{

   const int LENGTH = 9;

   char sample1[LENGTH];

   char sample2[LENGTH];

   

   cout << "Enter 9 characters to be converted to uppercase: ";

   

   for(int i = 0; i < LENGTH; i++){

   

       cin >> sample1[i];

       sample1[i] = toupper(sample1[i]);

       cout << sample1[i];

   }

   cout << endl;    

   cout << "Enter 9 characters to be converted to lowercase: ";

       

   for(int i = 0; i < LENGTH; i++){

       

       cin >> sample2[i];

       sample2[i] = tolower(sample2[i]);

       cout << sample2[i] ;

   }

   return 0;

}

Explanation:

- Declare the variables

- Ask the user for the characters

- Using for loop, convert these characters into uppercase and print them

- Ask the user for the characters

- Using for loop, convert these characters into lowercase and print them