Program to print no. of alphabets, digits & white spaces present in a string entered by a user

#include<stdio.h>

main()
{
char str[100];
int i,j,a=0,b=0,c=0;
char *p,*q,*r;
printf("Enter a string\n");

gets(str);
j=strlen(str);
p=&str;
for(i=0;i<=j-1;i++)
{
if(isalpha(*(p+i)))
{
a++;
}
if(isdigit(*(p+i)))
{
b++;
}
if(isspace(*(p+i)))
{
c++;
}
}
printf("Alphabets - %d, Digits - %d & Spaces - %d",a,b,c);
}

Continue reading “Program to print no. of alphabets, digits & white spaces present in a string entered by a user”