Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
- int main(void) {
- int i=0,up=0,low=0, space=0,digit=0,punc=0,control=0;
- char str[80] = " ICS 103 Programming in C !!";
- printf("The string= %s of length= %d\n", str,strlen(str));
- while(str[i] !='\0') {
- if (ispunct(str[i]))
- punc++;
- if (iscntrl(str[i]))
- control++;
- if(isdigit(str[i]))
- digit++;
- if(isspace(str[i]))
- space++;
- if(isupper(str[i]))
- up++;
- if(islower(str[i]))
- low++;
- i++;}
- printf("The number of digits = %d\n",digit);
- printf("The number of spaces = %d\n",space);
- printf("Upper case letters = %d\n", up);
- printf("Lower case letters = %d\n", low);
- printf("Punctuation characters = %d\n",punc);
- printf("Total control characters = %d\n", control);
- return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement