0
write c++ programme to read a string from the keyboard and count number of ovels and consonants in the string and display the results
2 Antworten
+ 1
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
int *p, i, vowels = 0, constant = 0;
char s[150];
cout << "Write a sentense (word limit 150)" << endl;
gets(s);
for (i = 0; i < strlen(s); i++)
{
if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u')
{
vowels++;
}
else if (s[i] == ' ')
continue;
else
{
constant++;
}
}
cout << "number of vowels are :: " << vowels << "\nAnd contants are :: " << constant << endl;
return 0;
}