Your logic makes no sense. All the stuff inside the while loop will only happen if rooms[i] is -1. So the tests for rooms[i]==1 and rooms[i]==0 can never be true. So freerooms and occupatedrooms will never be incremented.
Also, the while loop does not change the value of i, or the value of rooms[i]. So if rooms[i] is -1 at the start of the while loop, it will loop for ever.