The algorithm to compute theory prime implicates, a generalization of prime implicates, in propositional logic has been suggested in \cite{Marquis}. In this paper we have extended that algorithm to compute theory prime implicates of a knowledge base \(X\) with respect to another knowledge base \(\Box Y\) in modal logic \(\mathcal{K}\). We have also extended the query answering algorithm in modal logic \(\mathcal{K}\).