"i got this solution bt actually i can't understand the logic of the first loop???? will u plzz xplain me???"
#define EOL '\n'
int tag , count=0;
I don't know where you got it from - it's clear you didn't write it - but the loop is pretty simple.
It looks at each letter in the string in turn, until it comes to an end of line character (defined as a newline). First time in, it looks to see if the user started with a newline. Each time round the loop, it inserts a character from the user into the string. It then looks at it to see if the character it just inserted was the end of line character.
If you aren't sure what something does, draw it out on paper with a pencil: make an array a series of boxes, and manually work out what each instruction does, and copy it on the paper - with something this simple it is probably easier for you to see what is going on that way, than to look at memory with the debugger.