Our teacher told us that to differentiate between complex and compound sentence, just check if FANBOYS(for, and, nor, but, or, yet, so) conjunction is present or not. If it's present then it'll be compound sentence otherwise it would be a complex sentence. Is it right method? Or is there any other better way.
Yes and no
Yes, your teacher is correct that, in his or her class, a FANBOYS word will appear in a compound sentence. If not, you will be within your rights to complain about the question involved. You should be careful, though. Your post claims that every sentence is either compound or complex; some are both ("compound-complex"), some are neither ("simple").
Now, your teacher is wrong as a matter of grammar. The last sentence of the last paragraph included two compound sentences with no FANBOY word, just punctuation. It depends on the teacher's level of humility, but throwing that error in their face isn't likely to be productive. Assuming they aren't just annoyed, they'll explain of course they have to simplify things for the class, sit down, shut up, &c.
It's not important. Outside of English class, the term compound sentence is completely unimportant to English communication and where the exact line is drawn around its definition is irrelevant. Try to think in terms of independent and dependent clauses and how they play with each other and don't worry about the terminology past the test.
Here is another simpler way to a compound and complex sentence. A compound sentence is usually made up of two independent clauses joined together by a coordinating conjunction. It insinuates only two different happenings. While the latter usually insinuate more than two different happenings which are separated by punctuation marks and coordinating conjunctions or by subordinating conjunctions like;'that','when' and 'because'. For instance: I met her when I was in class three at college.