Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- int main()
- {
- char myString[300] = "30% of 40 students got a GPA greater than 3.5";
- int countA = 0, countD = 0, countO = 0;
- for (int i = 0; myString[i] != '\0'; i++) {
- if (isalpha(myString[i]))
- countA++;
- else if (isdigit(myString[i]))
- countD++;
- else
- countO++;
- }
- printf("Total Alphabets =%d \n", countA);
- printf("Total Digits =%d \n", countD);
- printf("Total Other Char =%d \n", countO);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement