-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhw.cpp
More file actions
68 lines (63 loc) · 1.04 KB
/
Copy pathhw.cpp
File metadata and controls
68 lines (63 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <iostream>
using namespace std;
int main()
{
int input;
cout<<"Enter a number:";
cin>>input;
int digit;
int n=0;
int c0=0,c1=0,c2=0,c3=0,c4=0,c5=0,c6=0,c7=0,c8=0,c9=0;
for(int j=0;;)
{
if(input!=0)
{ digit=input%10;
input=input/10;
if(digit==0)
{
c0++;
}
if(digit==1)
{
c1++;
}
if(digit==2)
{
c2++;
}
if(digit==3)
{
c3++;
}
if(digit==4)
{
c4++;
}
if(digit==5)
{
c5++;
}
if(digit==6)
{
c6++;
}
if(digit==7)
{
c7++;
}
if(digit==8)
{
c8++;
}
if(digit==9)
{
c9++;
}
}
else
{
break;
}
}
cout<<"0 was "<<c0<<" times in the number\n"<<"1 was "<<c1<<" times in the number\n"<<"2 was "<<c2<<" times in the number\n"<<"3 was "<<c3<<" times in the number\n"<<"4 was "<<c4<<" times in the number\n"<<"5 was "<<c5<<" times in the number\n"<<"6 was "<<c6<<" times in the number\n"<<"7 was "<<c7<<" times in the number\n"<<"8 was "<<c8<<" times in the number\n"<<"9 was "<<c9<<" times in the number\n";
}