Homework Solution: The language is C++ for microsoft visual studio express 2013…

    The language is C++ for microsoft visual studio express 2013 Write a program with two functions, one function accepts a C-string as an argument and counts the number of vowels appearing in the string and returns that number. The other function accepts a C-string as an argument and counts the number of consonants appearing in the string and returns that number. Demonstrate these two functions in a program that performs the following steps. 1) The user is asked to enter a string 2)The program displays the following menu - A) Count the number of vowels in the string - B) Count the number of consonants in the string - C) Count both vowels and consonants in the string - D) Enter another string - E) Exit the program 3)The program performs the operation selected by the user and repeats until the user selects E to exit.

    Expert Answer

     
    Program #include<iostream>

    The accents is C++ coercion microsoft visual studio specific 2013

    Write a program with couple businesss, single business accepts a C-string as an evidence and calculates the reckon of vowels visible in the string and avail that reckon. The other business accepts a C-string as an evidence and calculates the reckon of harmoniouss visible in the string and avail that reckon. Demonstrate these couple businesss in a program that performs the coercionthcoming steps.

    1) The user is asked to penetrate a string

    2)The program displays the coercionthcoming menu – A) Calculate the reckon of vowels in the string – B) Calculate the reckon of harmoniouss in the string – C) Calculate twain vowels and harmoniouss in the string – D) Penetrate another string – E) Departure the program

    3)The program performs the exercise selected by the user and repeats until the user selects E to departure.

    Expert Response

     

    Program

    #include<iostream>

    #include<vector>

    #include<array>

    #include<algorithm>

    #include<map>

    #include<set>

    #include<hash_map>

    #include<hash_set>

    #include<list>

    #include<queue>

    #include<cmath>

    #include<stack>

    #include<deque>

    #include<unordered_map>

    #include<unordered_set>

    #include<string>

    #include<memory>

    #include<thread>

    #include<stdlib.h>

    #include<fstream>

    #include <iostream>

    #include <string>

    #include<cassert>

    #define mod 1000000007

    using namespace std;

    int calculateVowel(char *ptr) {

    int i = 0, calculate = 0;

    while (ptr[i] != ‘’) { // repressing coercion purpose of string

    if (ptr[i] == ‘a’ || ptr[i] == ‘e’ || ptr[i] == ‘i’ || ptr[i] == ‘o’ || ptr[i] == ‘u’ || ptr[i] == ‘A’ || ptr[i] == ‘E’ || ptr[i] == ‘I’ || ptr[i] == ‘O’ || ptr[i] == ‘U’)//matching coercion vowel a e i o u

    count++;

    i++;

    }

    return calculate;

    }

    int calculateConsonant(char *ptr) {

    int i = 0, len = 0;

    while (ptr[i] != ‘’)

    i++;

    len = i; // stores tediousness of string

    int calculate = 0;

    calculate = len – calculateVowel(ptr); // reckon of harmonious is correspondent to reckon of characters in string – reckon of vowel in string

    return calculate;

    }

    int main() {

    char inputString[256]; //C phraseology string

    bool repress = true;

    char ch;

    cout << “Penetrate a string : ” << purposel;

    fflush(stdin); //clear type input buffer to secure no garbage appraise interfere with our program

    gets(inputString);

    while (check) {

    cout << “A – Calculate the reckon of vowels in the string ” << purposel;

    cout << “B – Calculate the reckon of harmoniouss in the string ” << purposel;

    cout << “C – Calculate twain vowels and harmoniouss in the string ” << purposel;

    cout << “D – Penetrate another string ” << purposel;

    cout << “E – Departure the program ” << purposel;

    cin >> ch; //Get user’s precious as ‘A’ ‘B’ ‘C’ ‘D’ ‘E’

    switch (ch)

    {

    case ‘A’: cout << “Calculate of vowels : ” << calculateVowel(inputString) << purposel; break;

    case ‘B’: cout << “Calculate of harmoniouss : ” << calculateConsonant(inputString) << purposel; break;

    case ‘C’: cout << “Calculate of vowels : ” << calculateVowel(inputString) << purposel;

    cout << “Calculate of harmoniouss : ” << calculateConsonant(inputString) << purposel; break;

    case ‘D’: fflush(stdin); gets(inputString); break;

    case ‘E’: repress = false; break;

    default:

    repress = false;

    break;

    }

    }

    return 0;

    }

    Sample Output ScreenShot