This is wrong
for(len=0; acno[len]!='\0'; len++);
C++ strings are not like C strings, they don't have '\0' terminators. If you want to know how long a C++ string is do this
len = acno.size();
Also when you have an error you call chkno again which is a bit strange but not actually wrong. But what you do do wrong is never return the value from the second call to chkno. What you should do is this
cout<<"Incorrect format.Please enter again";
cout<<"\nAccount No : "; cin>>ano;
return chkno(ano);
See how I've added a return.
For top marks for this exercise I think you should redesign your code. chkno
should be a function which just checks the account number (that's what it's called after all). So you should have it return a boolean value, true of false, depending on whether the account number is correct or not. Then you should put the enter/reenter your number loop in main. Like this
bool chkno(string acno)
{
...
}
int main()
{
cout<<"Account No : ";
cin>>acc_no;
while (!chkno(acc_no))
{
cout<<"Incorrect format.Please enter again";
cout<<"\nAccount No : ";
cin>>acc_no;
}
...
}
This is the normal way of writing this kind of task. It's better design because it has a cleaner separation of the two tasks, prompting the user to enter a number and checking if that number is correct.