Answer to Question #215620 in C++ for azmm

Question #215620

Study codes given below and add your own codes so that the program is able to:

- count and display the number of vowels exist in the array

- replace all those alphabets after ‘q’ with the symbol ‘*’ 

- display the latest contents of the array


#include<iostream>

using namespace std;


int main()

{

  char myArray[] = {'i', 'n', 't', 'e', 'r', 'n', 'a', 't', 'i','o', 'n', 'a', 'l'};


  //add your codes here

    

  cout<<endl;

  system("pause");

  return 0;

}



1
Expert's answer
2021-07-11T15:22:34-0400
#include<iostream>


using namespace std;


int main()


{


    char myArray[] = {'i', 'n', 't', 'e', 'r', 'n', 'a', 't', 'i','o', 'n', 'a', 'l'};
    //count and display the number of vowels exist in the array
    int count_vow=0;
    for(int i=0;i<13;i++){
        if(myArray[i]=='a'||myArray[i]=='e'||myArray[i]=='i'||myArray[i]=='o'||myArray[i]=='u')
            count_vow++;
    }
    cout<<"\nThe number of vowels existing in the array is "<<count_vow<<endl;
    
    //replace all those alphabets after ‘q’ with the symbol ‘*’ 
    for(int i=0;i<13;i++){
        if(myArray[i]=='r'||myArray[i]=='s'||myArray[i]=='t'||myArray[i]=='u'||myArray[i]=='v'||myArray[i]=='w'||myArray[i]=='x'||myArray[i]=='y'||myArray[i]=='z')
            myArray[i]='*';
    }
    
    //display the latest contents of the array
    for(int i=0;i<13;i++){
        cout<<myArray[i]<<"\t";
    }
    cout<<endl;


  system("pause");


  return 0;


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS