Advertisement
andruhovski

Untitled

Sep 11th, 2014
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <string.h>
  4. int main(void)  {
  5.   int i=0,up=0,low=0, space=0,digit=0,punc=0,control=0;
  6.   char str[80] = "    ICS 103 Programming in C !!";
  7.   printf("The string=  %s of length= %d\n", str,strlen(str));
  8.   while(str[i] !='\0') {
  9.     if (ispunct(str[i]))
  10.          punc++;
  11.     if (iscntrl(str[i]))
  12.          control++;
  13.     if(isdigit(str[i]))
  14.          digit++;
  15.     if(isspace(str[i]))
  16.          space++;
  17.     if(isupper(str[i]))
  18.          up++;
  19.     if(islower(str[i]))
  20.          low++;
  21.     i++;}
  22.     printf("The number of digits = %d\n",digit);
  23.     printf("The number of spaces = %d\n",space);
  24.     printf("Upper case letters = %d\n", up);
  25.     printf("Lower case letters = %d\n", low);
  26.     printf("Punctuation characters = %d\n",punc);
  27.     printf("Total control characters = %d\n", control);
  28.     return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement