-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path82ndProgram_Functions_12.cpp
More file actions
53 lines (47 loc) · 968 Bytes
/
Copy path82ndProgram_Functions_12.cpp
File metadata and controls
53 lines (47 loc) · 968 Bytes
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
#include<iostream>
using namespace std;
int countDigits(int);
int dividewithseven(int);
int buzz_count(int);
int main(){
int range ;
cout<<"Enter the range: ";
cin>>range;
cout<<"All buzz numbers in the "<< range<< "are: " << "\n";
for(int i=1;i<=range;i++){
if(dividewithseven(i) || buzz_count(i)){
cout<< "Buzz Number : "<<i<<"\n";
}
}
}
int countDigits(int i)
{
int s = 0;
while (i != 0)
{
// a = a%10(is un-necessary just for showing mod op)
i = i / 10;
s = s + 1;
}
return s;
}
int dividewithseven(int p){
if(p%7==0){
return p;
}
return 0;
}
int buzz_count(int q){
if(q%7!=0){
int m;
int c = countDigits(q);
for(int i = c ; i<=c; i++){
m = q%10;
q = q/10;
}
if(m==7){
return m;
}
}
return 0;
}