You can have multiple files in your OnlineGDB project. So you'd just do it as normally you'd do.
Write your (non-static) function in a separate file. Use extern to include that function from your main source file. Or, create a header for it and include that header file.
Here is a small example I created for you.
Good luck!