To generate a patch for your modified code. All you have to do is generate a diff between original and modified source files using the following command and save the output to the patch file.
diff -rup /home/ketan/unmodified_source.c /home/ketan/modified_source.c > patch.source.c
Now to apply patch to the original unmodified source. Use the following command from the appropriate location (/home/ketan) in our example.
patch -p0 < patch.source.c