From our rules:
(6) Do not post classroom or homework problems.
But I'll give a few hints before I close this thread.
EOF is a constant, often set to -1. Your "if(!EOF)" is waiting for -1 to become 0. You might check the return code from scanf to see it that is EOF. (But then your program is checking for when the user types cntl-D.)