Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- double average(int num)
- {
- double sum = 0;
- int len = 0;
- while (num > 0)
- {
- len++;
- sum += num % 10;
- num /= 10;
- }
- return sum / len;
- }
- int main() {
- std::cout << average(221584);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement