My friend says it's possible to write a C program that will print "hello world" without IF/WHILE/FOR
and without semicolons. After minimal research I told her it was not possible. Is it possible?
We can print "hello" or "hello world" or anything else in C without using semicolon. There are various ways to do so: Using if. Using switch.
We can simply write the text by using the line printf(“Hello World”); in the main() function.
C File I/O Programs This C program is used to print on the screen without using a semicolon. Semicolon must be used after printf function, but we can avoid this, by using printf function with if, while or switch statements.
#include <stdio.h> int main() { switch (printf("Hello, world!\n")) {} }
If your friend says "oh, you can't use switch either," then:
#include <stdio.h> int main(int argc, char *argv[printf("Hello, world!\n")]) {}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With