1.

Write a program to input a string and print the number of alphabets, numbers, spaces and special characters.it should be java program without the use array.

Answer»
  1. #include
  2. void stringcount(char *s)
  3. {
  4. static int i,alphabets=0,DIGITS=0,specialcharacters=0;
  5. if(!s[i])
  6.    {
  7.     printf("Alphabets = %d\n",alphabets);
  8.        printf("Digits = %d\n",digits);
  9.        printf("Special characters = %d", specialcharacters);
  10.        return;
  11.    }
  12.    else
  13.    {
  14.    
  15.     if((s[i]>=65 && s[i]<=90)|| (s[i]>=97 && s[i]<=122) )
  16.          alphabets++;
  17.        else if(s[i]>=48 && s[i]<=57)
  18.         digits++;
  19.        else
  20.         specialcharacters++;
  21.        i++;
  22.         stringcount(s);
  23.    }  
  24. }
  25. int main()
  26. {
  27.    char s[1000];  
  28.  
  29.    printf("ENTER  the string: ");
  30.    gets(s);
  31.    
  32.    stringcount(s);
  33. }

   

   

SOURCE> JAVA TUTORING



Discussion

No Comment Found