Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

Letters and Digits Total

#include <stdio.h>
#include <string.h>
 
int main()
{
    char s[1000]; 
    int i,alphabets=0,digits=0,specialcharacters=0;
 
    printf("Enter  the string : ");
    gets(s);
     
    for(i=0;s[i];i++)  
    {
        if((s[i]>=65 && s[i]<=90)|| (s[i]>=97 && s[i]<=122) )
          alphabets++;
        else if(s[i]>=48 && s[i]<=57)
         digits++;
        else
         specialcharacters++;
 
 	}
 	
     
    printf("Alphabets = %d
",alphabets);
    printf("Digits = %d
",digits);
    printf("Special characters = %d", specialcharacters);
    
 
    return 0;
}
Source by app.codechum.com #
 
PREVIOUS NEXT
Tagged: #Letters #Digits #Total
ADD COMMENT
Topic
Name
5+2 =