Writing the code for N qbit gate operation