Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- int main()
- {
- char text[100];
- int alpha = 0;
- int digit = 0;
- int punct = 0;
- printf("Enter your sentence: ");
- scanf("%[^\n]%*c", text);
- int i = 0;
- while (text[i]) {
- if (ispunct(text[i]))
- punct++;
- if (isdigit(text[i]))
- digit++;
- if (isalpha(text[i]))
- alpha++;
- i++;
- }
- printf("Your sentence contains:-\n");
- printf("Alphabets: %d\n", alpha);
- printf("Digits: %d\n", digit);
- printf("Punctuations: %d\n", punct);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement