Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New programs add #132

Merged
merged 2 commits into from
Oct 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}