If you use any code you found on the web or if you got something from the TA or a tutor or a friend you must give them credit with a comment in your code. Please remember that it is not ok to share or borrow code from other students in the class.
This is simply good practice in all creative endeavors. You must give credit to the creators. In this case, it will also avoid any problems with academic dishonesty. You might lose some points if you borrowed too much of your program from elsewhere (the web, the TA, your roommate) and gave them credit, but you would not be accused of academic dishonesty.
Failure to give credit could result in charges of academic dishonesty when the same bit of code also shows up in some other student's program because they also got it from the same place as you.