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;
}
#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;
}
Comments
Leave a comment