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

9th Sep 2016, 4:41 PM
Prahlad Kumar
2 Réponses
9th Sep 2016, 5:49 PM
Zen
Zen - avatar
+ 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; }
9th Sep 2016, 6:38 PM
Chinmay Majumdar
Chinmay Majumdar - avatar