Unfortunately some parts of your project are unclear. However I can answer the main question and give a suggestion for a possible cause of your problem:
I'm having an analog project where I have to amplify a weak signal coming out of a photo transistor.
I used LM741CN OpAmp for this and found out that nothing comes out as the output when connected to a RS232. [...] The project description was to create a background.
Just to let you know, this description of your project doesn't make sense e.g. there is no RS-232 connection shown on your schematic, and you want to "create a background" - a background what? Background lights? Background music? Background dancing? :-) There is no explanation in your schematic, so readers won't understand your actual project and cannot take those details of your project into account in any answers.
So I tried creating a basic inverting amplifier using this IC and the oscilloscope showed the same input signal like waveform as the output signal. I tried with another LM741CN IC and it gave the same result. Addition to that, the IC seems to be heating up a lot.
Any ICs heating up when they should be dissipating negligible power, is a clear indication that either they are faulty (perhaps counterfeit), or you have made a mistake in your circuit construction / design. Since you explain later that a replacement LM741CP worked OK in the same circuit, then that strongly suggests that the LM741CN ICs were faulty.
I tried 4 other 741CN ICs I bought from the shop the same day and all not working. (I assumed that it's not possible for 6 chips to be burnt like that)
Wrong assumption. Shops can get faulty batches of components, or perhaps counterfeit etc. Ebay and similar sources outside the official manufacturer's supply chain, have a higher chance of counterfeit components. Depending where your shop sourced the components, then these are some of the possibilities you should consider.
One of my friends had a LM741CP IC and I plugged into the same proto board with the same pin configuration and it worked.
Good! So as I explained above, this result tells us that the LM741CN ICs you tried earlier, are faulty.
So my question is are these LM741CN and LM741CP different?
No. LM741C = commercial temperature range LM741.
Do these last letters N and P mean anything like p type or n type?
In this context, no. The suffix "N" = plastic DIP package type is used by some manufacturers e.g. National Semiconductor / some Texas Instruments. The suffix "P" = plastic DIP package type is used by some other manufacturers - Texas Instruments also use the suffix "P" to indicate plastic DIP packages on some of their ICs. In this context, "N" and "P" suffixes both mean plastic DIP packages. That is all.
Other packaging type letters are also used, but these can all vary between manufacturers. Therefore use the manufacturer's logo on the top of the LM741CN and LM741CP ICs to identify the manufacturer, and then locate the relevant datasheet on their website if you want to find more details.
Was just wondering why CN didn't work when CP did.
Looking carefully at the sequence of events, there seems a possible cause. It seems that at least 4 of the 6 faulty LM741CN ICs came from the same source - the shop which you mentioned. What about the other 2 faulty LM741CN ICs - did they also come from the same shop? The working LM741CP IC came from a different source - your friend.
So the difference could also be described as (most? all?) LM741C ICs sourced from the shop did not work. An LM741C IC not sourced from the shop did work. Where do you see the difference now? :-)
Therefore it seems possible that some or all of your problems could be explained by a faulty or counterfeit batch of LM741CN ICs, since at least 4 of them (from your story) came from the same source.
Readers here cannot exclude the possibility that you somehow damaged the LM741CN ICs in your testing/experimentation, because we did not watch what you were doing. :-) However, as you describe the events in your story, it seems unlikely to me that you would damage all the LM741CN ICs and then not damage the LM741CP IC.
Therefore faulty LM741CN ICs seems a likely explanation, based on your description.
[As other members have already kindly stated, there are good reasons not to use the LM741 for new designs these days, unless you have good reasons to do so. Carefully read the 741 datasheet and understand its limitations.]