Back To C++ Single Dimensional Arrays Index
//program to input a sentence (char array) and count number of vowels in it using for loop #include
#include
void main() { char str[20]; char ch; int i; int count=0; clrscr(); printf("enter a string"); gets(str); for(i=0;str[i]!='\0';i++) { ch=str[i]; if((ch=='a') || (ch=='e') || (ch=='i') || (ch=='o') || (ch=='u')) { count++; } } printf("\nnumber of vowels in the string are %d",count); getch(); }