so for an exam which i have an hour left for, I need to write a vowel counter where the user inputs a c string, can anyone help me ? Here is the question: Write a function that takes a C string as an input and counts the number of vowels in the C string. Vowels must include both upper and lower case a, e, i, o, u, and y. You are not allowed to use any other functions to do this. Do not write a main function. Your function does not do any cin or cout. Remember, C strings are terminated with the '\0' character. Make sure to properly format all your code. LIKE an idiot, i did it without the c string and i'm having trouble switching the formatting. Can anyone help? Here is my current program.
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <iomanip>
using namespace std;
int main()
{
char sentence = ' ';
int count = 0 ;
cout << "Hello! Enter a sentence and I will count the number of vowels!";
cin.get(sentence);
cout << "VOWELS: " << endl;
while (sentence != '\n')
{
cin.get(sentence);
switch (toupper(sentence))
{
case 'A' : cout << sentence << ", ";
count++;
break;
case 'E' : cout << sentence << ", ";
count++;
break;
case 'I' : cout << sentence << ", ";
count++;
break;
case 'O' : cout << sentence << ", ";
count++;
break;
case 'U' : cout << sentence << ", ";
count++;
break;
case 'Y' : cout << sentence << ", ";
count++;
break;
}
}
cout << endl << "Your sentence had a total of" << count << " vowels!" << endl ;
system ("PAUSE");
return 0;
}