Write a program In C++ to count the numbers of Vowels & consonants in a string.
#include<iostream.h>
#include<conio.h> { char ch[20]; int i,con=0,vow=0; clrscr(); cout<<”Enter any name”; cin>>ch; for(i=0;ch[i]!=’\o’;i++) { If(ch[i]==’a’||ch[i]==’e’||ch[i]==’i’||ch[i]==’o’||ch[i]==’u’) { vow++; } else { con++; } } cout<<”vowels are :-“<<vow<<”\n”; cout<<”Consonants are :-“<<con; getch(); } |
|