https://www.codechef.com/SSC62021/problems/MOBNUM

https://www.codechef.com/SSC62021/problems/MOBNUM

Here’s a Java method for this:

static String checker(String no){
if(no.length()!=10) return “NO”;
try{
long n1=Long.parseLong(no);
if(no.charAt(0)==‘0’) return “NO”;
else return “YES”;
}
catch(Exception e){
return “NO”;
}
}

no -> the input telephone number

#include <iostream>
using namespace std;

int main() {
    int tt;cin>>tt;
    while(tt--){
        string s;cin>>s;
        if(s.length()  == 10){
            if(s[0] == '0'){
                cout<<"NO"<<endl;
            }else{
                bool ok=true;
                for(int i=0;i<10;i++){
                    if(s[i]-'0'>=0 && s[i]-'0'<=9){
                        continue;
                    }else{
                        ok=false;
                        break;
                    }
                }
                if(ok)
                 cout<<"YES"<<endl;
                else
                 cout<<"NO"<<endl;
            }
        }else{
            cout<<"NO"<<endl;
        }
    }
	return 0;
}

This is the an accepted C++ code. If you are facing a problem in the solution, please first try to look at the available solutions, then ask specific doubts.