Skip to content

Commit

Permalink
Merge pull request #132 from Vaibzz/new-programs-add
Browse files Browse the repository at this point in the history
New programs add
  • Loading branch information
ambujraj committed Oct 2, 2018
2 parents 99db795 + fca0bfb commit 25cab11
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions telephone_number_validator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include<bits/stdc++.h>

using namespace std;
int main()
{
string number;
cout<<"Enter Mobile Number: ";
cin>>number;

bool flag = 0;
int i = 0;
while(number[i])
{
if(number[i] < 48 || number[i] > 57) //check if all the characters are numeric if not we set flag = 1
{
flag = 1;
break;
}
i++;
}

if(!flag && number.length() == 10) //check if flag is not set and length is 10.
cout<<"Phone Number Valid";
else
cout<<"Phone Number NOT Valid";

return 0;
}

0 comments on commit 25cab11

Please sign in to comment.