Skip to content

Commit 247f298

Browse files
authored
Merge pull request #1947 from Prabsimar-singh/patch-4
SolutionByPrabsimar.cpp
2 parents 3ace675 + 0b8799a commit 247f298

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
else
30+
cout << "\n Not a positive integer";
31+
return 0;
32+
}

0 commit comments

Comments
 (0)