Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m answering the folling quesion for class: Write a progam that reads a string

ID: 3646867 • Letter: I

Question

I'm answering the folling quesion for class:

Write a progam that reads a string and outputs the number of times each
lowercase vowel appears in it. Your program must contain a function with
one of its parameters as a string variable and return the number of times each
lowercase vowel appears in it. Also write a program to test your function. (Note
that if str is a variable of type string, then str.at(i) returns the character at
the ith position. The position of the first character is 0. Also, str.length()
returns the length of the str, that is, the number of characters in str.)


#include <iostream>
#include <string>

using namespace std;

int vowelsNumberof (string, char); //Function Label

void main()
{
string str;

cout << "Enter a string :" << endl; //Enter String
cin >> str; //Input string

cout << "The number of a's:" << vowelsNumberof (str, 'a') << endl; //Function to count a's

cout << "The number of e's:" << vowelsNumberof (str, 'e') << endl; //Function to count e's

cout << "The number of i's:" << vowelsNumberof (str, 'i') << endl; //Function to count i's

cout << "The number of o's:" << vowelsNumberof (str, 'o') << endl; //Function to count o's

cout << "The number of u's:" << vowelsNumberof (str, 'u') << endl; //Function to count u's

system ("pause");
}

int vowelsNumbersof(string str) //Defines variable string

{
int i, ch = 0; //Defines type and value

for(i=0;i<(int)str.length();i++) //Sets to 0 and sets length
if(str.at(i)==ch) ch++; //Returns to ith position (0)

return ch;
}



Here is my return error:


1>------ Build started: Project: ch7, Configuration: Debug Win32 ------
1> ch7.cpp
1>ch7.obj : error LNK2019: unresolved external symbol "int __cdecl vowelsNumberof(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,char)" (?vowelsNumberof@@YAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@D@Z) referenced in function _main
1>C:UsersBrDesktopSchoolC++ 1ch7Debugch7.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Explanation / Answer

#include #include #include int count_letter(const std::string& s, char c) { return std::count(s.begin(), s.end(), c); } int main() { std::cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote