>And about C hat and C++ hat, I'll Google and see what they are.
Don't waste your time doing that. What Salem was trying to convey was that people has the tendency to write C/C++ implying that it is, somehow just a programming language. When indeed C is not C++, neither C++ is C, contrary to the believe of many books and new learners. It is better to treat them as they are, two completely different programming languages with some similar syntax.
> new allocates memory in C++ and java, how its different from malloc?
Closely related to the topic. C do not have garbage collector, therefore, every time you call malloc to allocate some block of memory you must make sure that when that memory is not needed you release it by making a call to the function free().
Get to the habit of making sure that each call to malloc needs to be verified by checking that there was not problem reserving that block of memory.
e.g.
example
Not related to the topic, but some how not possible to dismiss are those call to scanf() to read an integer from user. I don't want to overwhelm you, but feeling a waste of time to learn something you are going to have to unlearn later; hence my intention to warn you now.
Don't use scanf() for reading from input. Verifying what the user enters is very hard, specially strings.
Some …