-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode7.cpp
More file actions
71 lines (65 loc) · 1.2 KB
/
Copy pathcode7.cpp
File metadata and controls
71 lines (65 loc) · 1.2 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
69
70
71
#include <iostream>
using namespace std;
int SOD(int n){
if(n%10==n){
return n;
}
return (n%10)+SOD(n/10);
}
int REV(int n,int sum){
if(n%10==n){
return (sum*10)+n;
}
int remain = n%10;
if(n!=0){
sum = (sum*10)+remain;
}
else{
sum=sum*10;
}
return REV(n/10, sum);
}
int POD(int n)
{
if(n%10==n){
if(n==0){
return 1;
}
return n;
}
int remain = n%10;
if(remain==0){
return POD(n/10);
}
else{
return remain*POD(n/10);
}
}
bool pallindrome(int n){
return(n==REV(n,0));
}
int zero=0;
void countzero(int n){
if(n%10==n){
if(n==0){
::zero++;
return;
}
return;
}
int remain = n%10;
if(remain==0){
::zero++;
}
countzero(n/10);
}
int main() {
cout<<"Sum of Digit: "<<SOD(12304)<<endl;
cout<<"Reversed Digit: "<<REV(123321,0)<<endl;
cout<<"Product of Digit: "<<POD(123040)<<endl;
cout<<"Pallindrome: "<<pallindrome(123321)<<endl;
countzero(101000); //wrong output for number starting with zero ex--> 0100
//
cout<<"No of zero: "<<::zero;
return 0;
}