I saw a problem which asks you to print "Hello World" using the fewest characters, including spaces. How can I further shorten this code? Thank you in advance!

int main(){printf("Hello World");}
  • 2
    \$\begingroup\$ See the shortest C++ solution by James in “Hello, World!”. Note that as it is, your question doesn't meet this site's expectations so will be probably closed. \$\endgroup\$
    – manatwork
    Commented Nov 20, 2020 at 4:09
  • 3
    \$\begingroup\$ You can remove #include <iostream> and use puts instead of printf (assuming you're using a kind compiler that allows you to use these functions without including cstdio) (edit: it seems that neither G++ nor clang are kind enough and I was wrong) This question should almost certainly be tagged [tips]. \$\endgroup\$ Commented Nov 20, 2020 at 4:10
  • \$\begingroup\$ @manatwork i tried it but i can't compile it. \$\endgroup\$
    – Summer
    Commented Nov 22, 2020 at 13:46
  • \$\begingroup\$ @Summer, it works for me: pastebin.com/Qr9hM6g8 Note that as we regularly force the boundaries of compilers/interpreters, warnings are acceptable by default here. \$\endgroup\$
    – manatwork
    Commented Nov 22, 2020 at 19:52


Browse other questions tagged or ask your own question.