Niloy007

Siam 2

Jun 12th, 2021
647
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4.  
  5. int main()
  6. {
  7.     char myString[300] = "30% of 40 students got a GPA greater than 3.5";
  8.     int countA = 0, countD = 0, countO = 0;
  9.  
  10.     for (int i = 0; myString[i] != '\0'; i++) {
  11.         if (isalpha(myString[i]))
  12.             countA++;
  13.         else if (isdigit(myString[i]))
  14.             countD++;
  15.         else
  16.             countO++;
  17.     }
  18.  
  19.     printf("Total Alphabets =%d \n", countA);
  20.     printf("Total Digits =%d \n", countD);
  21.     printf("Total Other Char =%d \n", countO);
  22.     return 0;
  23. }
RAW Paste Data