Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hello world in C without semicolons and without IF/WHILE/FOR statements [closed]

Tags:

c

puzzle

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?

like image 360
Alex Gordon Avatar asked Nov 10 '10 18:11

Alex Gordon


People also ask

Can we print Hello World Without semicolon C?

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.

How can you print hello without semicolon?

We can simply write the text by using the line printf(“Hello World”); in the main() function.

Can we write ac program without semicolon?

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.


1 Answers

#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")]) {} 
like image 92
cdhowie Avatar answered Sep 28 '22 08:09

cdhowie