Question: Use C++ no advance techniques, follow the instructions. Also when you do the swap, you may NOT hard code the swap. You have to use

Use C++ no advance techniques, follow the instructions. Also when you do the swap, you may NOT hard code the swap. You have to use some loop that moves through the array and figures out when/where to swap.
#include
#include
#define NUM_COLS 5
#define NUM_ROWS 5
using namespace std;
void displayMenu(){
cout
cout
cout
cout
cout
cout
}
void interchangeCols(char array[][NUM_COLS]){
for(int i=0;i //swapping elements at column 2 (index 1) and column 5 (index 4) char temp=array[i][1]; array[i][1]=array[i][4]; array[i][4]=temp; } } void countVowels(char array[][NUM_COLS]){ int count=0; for(int i=0;i for(int j=0;j char c=array[i][j]; if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u'){ //lower case vowel count++; }else if(c=='A' || c=='E' || c=='I' || c=='O' || c=='U'){ //upper case vowel count++; } } } cout } void display(char array[][NUM_COLS]){ cout for(int i=0;i for(int j=0;j char c=array[i][j]; cout } cout } cout } void search(char array[][NUM_COLS]){ char c; //getting character to search cout cin>>c; int count=0; for(int i=0;i for(int j=0;j if(c==array[i][j]){ //found, updating count count++; } } } cout } int main(){ char array[NUM_ROWS][NUM_COLS]={ { 's','l','o','a','n'}, {'h','o','r','s','e'}, {'e','g','r','i','t'}, {'h','o','u','s','e'}, {'w','a','t','e','r'} }; int choice=0; while(choice!=5){ //displaying menu, getting choice displayMenu(); cin>>choice; //handling choice switch(choice){ case 1: interchangeCols(array); cout break; case 2: countVowels(array); break; case 3: display(array); break; case 4: search(array); break; } } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
