#include<stdio.h> #include<string.h> main() { int a,b,c=1,d=0,e=0,f=0,g=1; char s1[100],s2[100]; printf("Enter a string\n"); gets(s1); b=strlen(s1); for(a=1;a<=b-1;a++) { if(isalpha(s1[a])) { c++; } if(isspace(s1[a])) { e++; } if(isdigit(s1[a])) { f++; } } printf("Digits = %d, Alphabets = %d, Space = %d",f,c,e); }
Output:
Enter a string hi 55 Digits = 2, Alphabets = 2 & Space = 1