To cite either a complete computer program or just a program fragment, you will need the following information. Provide as much as available.
Provide the citation information as a comment placed above the reused code. For example:
/*
Title: <title of program/source code>
Author: <author(s) names>
Date: <date>
Code version: <code version>
Type: <type>
Availability: <where it's located>
*/