-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #132 from Vaibzz/new-programs-add
New programs add
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |