My doubt is that, the program works fine if I enter a password that fills the array. However if I enter a password such as \"apple25\", I think it counts the blank spaces in the
Point 1. Always initialize your automatic local variables. Saves you from accidentally accessing un-initialized value.
char arr[10] = {0};
Point 2. Always limit your input length. Saves you from running into undefined behavior by overrunning the allocated memory by longer-than-expected input.
scanf("%9s",arr );
Point 3. Use strlen() to loop over only the valid part of input.