Back To C Single Dimensional Arrays Index
//program to input a string and find number of vowels,consonants,digits and other characters #include
#include
#include
void main() { char str[20]; char ch; int i,len; int vowels=0,cons=0; int digits=0,other=0; int v=0; clrscr(); printf("\nenter a string"); gets(str); len=strlen(str); for(i=0;i
='a') && (ch<='z')) { cons++; } else if((v==0) && (ch>='A') && (ch<='Z')) { cons++; } else if((ch>='0') && (ch<='9')) { digits++; } else { other++; } } printf("\nnumber of vowels are %d",vowels); printf("\nnumber of consonants are %d",cons); printf("\ndigits are %d",digits); printf("\nother are %d",other); getch(); }