Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int digits(int num)
- {
- int amount = 0;
- while (num != 0)
- {
- num /= 10;
- amount++;
- }
- return amount;
- }
- int main()
- {
- int num;
- std::cout << "Input number: ";
- std::cin >> num;
- std::cout << "The number of digits: " << digits(num) << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment