Write program to count upper and lower case letter
Use ctype functions.
#include <stdio.h> #include <ctype.h> int main()//from w w w .j av a2 s. c o m { char phrase[] = "This is a Test."; int index; int alpha,blank,lower,punct,upper; alpha = blank = punct = lower = upper = 0; /* gather data */ index = 0; while(phrase[index]) { if(isalpha(phrase[index])) alpha++; if(isblank(phrase[index])) blank++; if(ispunct(phrase[index])) punct++; if(islower(phrase[index])) lower++; if(isupper(phrase[index])) upper++; index++; } /* print results */ printf("\"%s\"\n",phrase); puts("Statistics:"); printf("%d alphabetic characters\n",alpha); printf("%d blanks\n",blank); printf("%d punctuation symbols\n",punct); printf("%d lower case letters\n",lower); printf("%d upper case letters\n",upper); return(0); }