[Solved] why the following code gives the first mobile no. irrespective of name


You cannot compare strings using = (or even by ==, for that matter) operator. You need to use strcmp() for that.

In your code, inside mobileno() function,

if( s="katrina" )

is essentially trying to assign the base address of the string literal "katrina" to s. It is nowhere near a comparison.

That said,

  1. Never use gets(), it suffer from buffer overflow problem. Use the safer alternative, fgets()
  2. Recommended signature of main() is int main(void)

solved why the following code gives the first mobile no. irrespective of name