Skip to content

Commit

Permalink
Lucky_Number | C++ #816
Browse files Browse the repository at this point in the history
Lucky_Number | C++
  • Loading branch information
div-bargali authored Oct 30, 2020
2 parents 762d6d4 + 0ed746a commit 9a2f56c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions C++/Algorithms/Mathematical/Lucky_number.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include<iostream>
using namespace std;

int main() {
int n,n1,n2,d1,d2,ct=0,flag=0;
cout<<"Enter a number: ";
cin>>n1;
n2=n1;
n=n1;
while(n1>0)
{
d1=n1%10;
while(n2>0)
{
d2=n2%10;
if(d1==d2)
ct++;
n2=n2/10;
}
if(ct>1)
{
flag=1;
break;
}
ct=0;
n2=n;
n1=n1/10;
}
if(flag==1)
cout<<n<<" is not a lucky number";
else
cout<<n<<" is a lucky number";
return 0;
}

0 comments on commit 9a2f56c

Please sign in to comment.