1
\$\begingroup\$

In some languages such as PHP you need to add these <?php ?> before you can start to program in PHP. And in C++ too. int main(){}. When answering a question, must I add the tags/function?

| |
\$\endgroup\$
2
\$\begingroup\$

For PHP, no. With the -r flag, you can run the code without surrounding tags. The -r switch doesn't contribute to the byte count in this case.

For C, you have two options:

  1. Submit a full program.

    This requires a main function.

  2. Submit a function.

    By default, all submissions may be full programs or functions. For compiled languages, a function is usually shorter, especially if you stick to C89 and use a permissive compiler such as gcc.

    For example, to add two numbers, the function

    f(a,b){return a+b;}
    

    is considered a valid submission.

If you enjoy golfing in C, Tips for golfing in C is a good read.

| |
\$\endgroup\$
  • \$\begingroup\$ For C++ you can also submit a lambda. \$\endgroup\$ – Martin Ender Oct 20 '16 at 19:50

Not the answer you're looking for? Browse other questions tagged .