When you use books or other references, such as web sites, you must document those sources. This is true whether you use source code verbatin or adapt it to your needs. There is nothing wrong with using published and publicly available code, but you must give credit to the source. If you fail to credit the source, you are implicitly claiming that the code is your own work - and that is plaigarism. You should work individually on your programs, do not ask other students for assistance and do not assist other students.
Academic dishonesty is a serious offense and the punishment is sever.
If you are caught cheating, you will receive a failing grade for the course. You will fail if you cheat.