prev


Character Arrays

77.Count upper lower digit special chars (12.05.2010)

/*
Program# 77
date : 28-12-2008
Count no.of uppercase ,lowercase ,digit and special chars
*/

#include <stdio.h>
main(){
char a[100];
int i,u=0,l=0,d=0,s=0;

i=0;
scanf("%c",&a[i]);
while(a[i]!='$'){
i++;
scanf("%c",&a[i]);
}
a[i]='\0';

i=0;
while(a[i]!='\0'){
if(a[i]>=65 && a[i]<=90)
u=u+1;
else
if(a[i]>=97 && a[i]<=122)
l=l+1;
else
if(a[i]>=48 && a[i]<=57)
d=d+1;
else
s=s+1;

i++;
}

printf("\n No.of uppercase : %d",u);
printf("\n No.of lowercase : %d",l);
printf("\n No.of digit: %d",d);
printf("\n No.of special char : %d",s);
}



next
blog comments powered by Disqus