We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 3ace675 + 0b8799a commit 247f298Copy full SHA for 247f298
1 file changed
Basic/Count Number of Digits in An Integer/SolutionByPrabsimar.cpp
@@ -0,0 +1,32 @@
1
+//Number of digits in an Integer
2
+
3
+#include <iostream>
4
+using namespace std;
5
6
+int main()
7
+{
8
+ long long int num;
9
+ long long int n;
10
+ cout << "Enter a positive integer ";
11
+ cin >> num;
12
+ n=num;
13
14
+ int c = 0;
15
+ while (n > 0)
16
+ {
17
+ n /= 10;
18
+ c++;
19
+ }
20
21
+ if (num >= 0)
22
23
+ if (num != 0)
24
+ cout << "\n Number of Digits in " << num << " is " << c;
25
+ else
26
+ cout << "\n Number of Digits in " << num << " is 1";
27
28
29
30
+ cout << "\n Not a positive integer";
31
+ return 0;
32
0 commit comments