fork download
  1. #include <iostream>
  2.  
  3. int AveChar(char str[]){//not work for EBCDIC.
  4. unsigned int Add = 0;
  5. std::size_t Idx = 0;
  6.  
  7. while (str[Idx] != '\0') Add += str[Idx++];
  8.  
  9. return Add / Idx;
  10. }
  11.  
  12. int main(){
  13.  
  14. char str[] = "BASIC";
  15.  
  16. char C = (char)AveChar(str);
  17.  
  18. std::cout << str << " -> " << C << std::endl;
  19.  
  20. return 0;
  21.  
  22. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
BASIC -> F