Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Declare a two dimensional array of the type char named Table of the size 5 x 4,

ID: 3833134 • Letter: D

Question

Declare a two dimensional array of the type char named Table of the size 5 x 4, i.e. 5 rows and 4 columns. Initialize the array with random capital alphabets and display the array. Display the count of all the vowels in the array. Replace all the vowels with their lowercase counterparts and display the array again. Please note that your output will be different because the array is initialized randomly. S H 2 M I M M Y G O K O B U F I C I U A M B 0 R J U Total Uowels 7 Total Vowels 4 U R S H M i M M Y C i o B u F i a MB Z o R J u W Q U R

Explanation / Answer

#include<iostream.h>
#include <stdlib.h>
#include <time.h>

void main()
{
   char data[5][4];
   int i, j;
   int num;
   int vowel_count;

   srand(time(NULL));
   for (i=0; i<5; i++){
       for (j=0; j<4; j++){
           num = rand() % 26;
           data[i][j] = static_cast<char>( 'A' + num );
       }
   }
   vowel_count = 0;
      
   for (i=0; i<5; i++){
       for (j=0; j<4; j++){
           if (data[i][j] == 'A' || data[i][j] == 'E' || data[i][j] == 'I'
               || data[i][j] == 'O' || data[i][j] == 'U')
           {
               vowel_count++;
           }
           cout << data[i][j] << " ";
       }
       cout << endl;
   }
   cout << "Total vowels: " << vowel_count << endl;  
   for (i=0; i<5; i++){
       for (j=0; j<4; j++){
           if (data[i][j] == 'A' || data[i][j] == 'E' || data[i][j] == 'I'
               || data[i][j] == 'O' || data[i][j] == 'U')
           {
               data[i][j] = data[i][j] + 32;
           }
           cout << data[i][j] << " ";
       }
       cout << endl;
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote