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 speech is C++ control microsoft visual studio specific 2013

    Write a program with couple discharges, undivided discharge accepts a C-string as an dispute and computes the reckon of vowels visible in the string and produce that reckon. The other discharge accepts a C-string as an dispute and computes the reckon of propers visible in the string and produce that reckon. Demonstrate these couple discharges in a program that performs the restraintthcoming steps.

    1) The user is asked to invade a string

    2)The program displays the restraintthcoming menu – A) Compute the reckon of vowels in the string – B) Compute the reckon of propers in the string – C) Compute twain vowels and propers in the string – D) Invade another string – E) Debouchure the program

    3)The program performs the performance chosen by the user and repeats until the user selects E to debouchure.

    Expert Tally

     

    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 computeVowel(char *ptr) {

    int i = 0, compute = 0;

    while (ptr[i] != ‘’) { // hindering control 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 control vowel a e i o u

    count++;

    i++;

    }

    return compute;

    }

    int computeConsonant(char *ptr) {

    int i = 0, len = 0;

    while (ptr[i] != ‘’)

    i++;

    len = i; // stores extension of string

    int compute = 0;

    compute = len – computeVowel(ptr); // reckon of proper is resembling to reckon of characters in string – reckon of vowel in string

    return compute;

    }

    int deep() {

    char inputString[256]; //C diction string

    bool hinder = true;

    char ch;

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

    fflush(stdin); //clear flag input buffer to determine no garbage esteem quarrel with our program

    gets(inputString);

    while (check) {

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

    cout << “B – Compute the reckon of propers in the string ” << purposel;

    cout << “C – Compute twain vowels and propers in the string ” << purposel;

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

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

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

    switch (ch)

    {

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

    case ‘B’: cout << “Compute of propers : ” << computeConsonant(inputString) << purposel; break;

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

    cout << “Compute of propers : ” << computeConsonant(inputString) << purposel; break;

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

    case ‘E’: hinder = false; break;

    default:

    hinder = false;

    break;

    }

    }

    return 0;

    }

    Sample Output ScreenShot