I am writing a program that counts the number of vowels that the user inputs but it is giving me the error "Variable declaration in condition must have an initializer". How do you fix it?
#include <iostream>
using namespace std;
int isVowel(char c)
{
char Vowels[] = {'A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u'};
if (c in Vowels)
return true;
}
int main()
{
int n;
int numVowel = 0;
char c;
cin >> n;
for (int i = 0; i < n; ++i)
{
cin >> c;
if (isVowel(c))
numVowel++;
}
cout << "Number of vowels = " << numVowel << endl;
return 0;
}
Aucun commentaire:
Enregistrer un commentaire