Thursday, 13 February 2014

write a program to input 10 character into array and calculate the no.of alphabets,numeric,and special character


/* input 10 character into array and calculate the no.of alphabets,numeric,and special character*/
#include<stdio.h>
main()
{
char a[10];
int i,x=0,y=0,z=0;
for(i=0;i<10;i++)
{
printf("enter the array of character a[%d] =",i);
scanf(" %c",&a[i]);
}
for(i=0;i<10;i++)
{
if(a[i]>=48 && a[i]<=57)
{
x++;}
else if((a[i]>=65 && a[i]<=90)||(a[i]>=97 &&a[i]<=122))
{
y++;
}
else
{
z++;
}
}
printf("number of numeric char is %d\n:",x);
printf("number of alphabet char is %d\n:",y);
printf("number of special char is %d\n:",z);
}

No comments:

Contact Form

Name

Email *

Message *