Please let me know if anything is required.
Copyable code:
#include <fstream>
#include <iostream>
#include <string.h>
using namespace std;
//checking if it is vowel
bool isVowel(char c)
{
if(c=='a' || c=='e' ||c=='i' ||c=='o' || c=='u')
{return true;}
else
{return false;}
}
//function to count the number of vowels
int countVowels(string s)
{
int vowelsCount=0;
for (int i=0;i<s.length();i++)
{
if(isVowel(s[i]))
{
vowelsCount++;
}
}
return vowelsCount;
}
//counting the words
int countWords(string s)
{
int wordsCount=0;
if(s.length()>0)
{
//splitting the string with delimiter space
string delimiter = " ";
size_t position = 0;
string word;
while ((position = s.find(delimiter)) != std::string::npos)
{
word = s.substr(0, position);
wordsCount++;
s.erase(0, position + delimiter.length());
}
wordsCount++;
}
return wordsCount;
}
int main()
{
// taking the input file name input from the user
cout<<"Please enter the input file name: ";
string infile;
cin>>infile;
string line;
ifstream myfile1 (infile);
if (myfile1.is_open())
{
//reading single string from a file
getline(myfile1,line);
{
}
}
//printing the number of words in the string
int wc=countWords(line);
cout<<"Number of words in "<<line<<" are:
"<<wc<<"\n";
int vc=countVowels(line);
cout<<"Number of vowels in "<<line<<" are:
"<<vc<<"\n";
return 0;
}
Sample input:

Copyable sample input:
Rayyan is counting words and vowels
Sample output:

Write a C++ program that will count the number of words and vowels in a sentence....
Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. #include <iostream> #include <string> using namespace std; void removeVowels(string& str); bool isVowel(char ch);...
‘C’ programming language question Write a MENU DRIVEN program to A) Count the number of vowels in the string B) Count the number of consonants in the string C) Convert the string to uppercase D) Convert the string to lowercase E) Display the current string X) Exit the program The program should start with a user prompt to enter a string, and let them type it in. Then the menu would be displayed. User may enter option in small case...
C++ 1) Write a function named WordCount, which determines the number of words in a “C type” string. The function will have one parameter (the address of the string) and will return the number of words (words are separated by one or more spaces). (15 points) 2) Write a function named VowelConsonant which will have three parameters - all “C type” strings. The function will place all vowels (the characters a, e, i, o, u) from the first string into...
I need this in Visual Studio C++
Write a function that count the number of vowels, the number of consonants and the average number of letters in each word. The function accept a C-String (char array) or a string object as an argument and return the number of vowels, number of consonants and the average number of letters in each word. Problem: Requirements: . Use pointers as part of the solution Read a string from a text file. . Write...
Write a function called countWords that inputs several lines of text and uses strtok to count the total number of words. Assume that the words are separated by either spaces or newline characters. int countWords(char *string) { }
Write a C++ program that repeatedly reads lines until an EOF is encountered. As each line is read, the program strips out all characters that are not upper or lower case letters or spaces, and then outputs the line. Thus, the program acts as a filter and issues no prompt. There are many ways this program could be written, but to receive full credit, you must observe the following: Place your code in a file called filterChars.cpp. The program should...
Document2 Tell me ign Layout References Mailings Review View 1. Write a program called Lab18C that searches for a number in an array. T a. Write a bool function named search that receives 3 parameters: an int array, an int containing the length of the array, and an int number to search for. Return true if the number is in the array and false otherwise. b. Write a void function called fillArray with the array as a parameter that uses...
Write a program that write a value-returning function, isVowel, that returns the value true if a given character is a vowel and otherwise returns false. You must insert the following comments at the beginning of your program and write our commands in the middle: Write a C++ Program: /* // Name: Your Name // ID: Your ID */ using namespace std; #include <iostream> using namespace std; bool isVowel(char ch); int main() { char ch; … … ...
Document2 Tell me Layout References Mailings Review View 1. Write a program named Lab17B that will read 2 strings and compare them. a. Create a bool function named compareLetters that will accept 2 string variables as parameters and will return true if the strings have the same first letters and the same last letters. It will return a false otherwise. b. Create a bool function named inside that will accept the 2 string variables in the order they were entered)...
Write a recursive method that counts the number of vowels in a string. It must return the number of vowels. Use appropriate parameters as needed. Hint: There's an ArrayList method called contains that might make checking whether a character is a vowel easier.