Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- main(void){
- int ch, coun1 = 0, coun2 = 0, coun3 = 0, sum1 = 0, sum2 = 0, sum3 = 0;
- while((ch = getchar()) != '\n'){
- if(isalpha((char)ch)){
- if(isupper((char)ch)){
- coun1++;
- sum1 += ch;
- }else{
- coun2++;
- sum2 += ch;
- }
- }else{
- if(isdigit((char)ch)){
- coun3++;
- sum3 += ch;
- }
- }
- }
- printf("The average ascii value of the alpha numeric characters is %f\n", (float)(sum1+sum2+sum3) / (coun1+coun2+coun3));
- printf("The average numeric character is %f\n", (float)sum3 / coun3);
- printf("The average alpha character is %f\n", (float)sum2 / coun2);
- printf("The average upper case character is %f\n", (float)sum1 / coun1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement