C语言教程-C程序:不使用分号打印"hello"

C语言教程-我们可以在C语言中以不使用分号的方式打印"hello"、"hello world"或其他内容。有各种方法可以实现:
使用if语句 使用switch语句 使用循环等等。
程序1:使用if语句
让我们看一个简单的C语言示例,使用if语句在不使用分号的情况下打印"hello world"。
#include <stdio.h>
int main() {
if (printf("hello world")) {
}
return 0;
}
输出:
hello world
程序2:使用switch语句
让我们看一个简单的C语言示例,使用switch语句在不使用分号的情况下打印"hello world"。
#include <stdio.h>
int main() {
switch (printf("hello world")) {
}
return 0;
}
输出:
hello world
程序3:使用while循环
让我们看一个简单的C语言示例,使用while循环在不使用分号的情况下打印"hello world"。
#include <stdio.h>
int main() {
while (!printf("hello world")) {
}
return 0;
}
输出:
hello world