From 90a0ad6dd1559bc42cf2fb24131361ac138eba10 Mon Sep 17 00:00:00 2001 From: sristi sharma <54236156+24sristi@users.noreply.github.com> Date: Sun, 25 Oct 2020 01:59:28 +0530 Subject: [PATCH] Create countOfDigitsInaNumber.cpp Given an integral number N. The task is to find the count of digits present in this number within O(1) time complexity. --- countOfDigitsInaNumber.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 countOfDigitsInaNumber.cpp diff --git a/countOfDigitsInaNumber.cpp b/countOfDigitsInaNumber.cpp new file mode 100644 index 0000000..b98ab84 --- /dev/null +++ b/countOfDigitsInaNumber.cpp @@ -0,0 +1,10 @@ +#include +#include +using namespace std; +int main() { + int n; + cin>>n; + int k = log10(n)+1; + cout<