Advertisement
biswasrohit20

is

Apr 27th, 2021
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. int main()
  6. {
  7.  
  8. char text[100];
  9. int alpha = 0;
  10. int digit = 0;
  11. int punct = 0;
  12. printf("Enter your sentence: ");
  13. scanf("%[^\n]%*c", text);
  14. int i = 0;
  15. while (text[i]) {
  16. if (ispunct(text[i]))
  17. punct++;
  18. if (isdigit(text[i]))
  19. digit++;
  20. if (isalpha(text[i]))
  21. alpha++;
  22. i++;
  23. }
  24.  
  25. printf("Your sentence contains:-\n");
  26. printf("Alphabets: %d\n", alpha);
  27. printf("Digits: %d\n", digit);
  28. printf("Punctuations: %d\n", punct);
  29. return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement