+ 6
How to print Hello in c without using semicolon ?😉😉😉
7 ответов
+ 4
Well, I found two ways to do it. One by myself, and the other one is googled stuff. So I am myself trying to figure out how does it work.
First one is pretty simple.
#include <stdio.h>
int main() {
if(printf("hello world"))
{
}
}
The second one is:
https://code.sololearn.com/cAi6wHx0KAvk/?ref=app
If someone knows how does the second code work, then please answer this:
https://www.sololearn.com/Discuss/1689859/?ref=app
+ 3
printf returns the total number of characters it prints. Here, "hello world" has 11 characters, so printf will return 11.
Now, the statement is reduced to if(11) { } which is true because if(0) is false, and for other numbers other than 0, its true.
This is how it works!
+ 3
printf() is a function with return type 'int', so it does both the job. It prints what you send it inside the braces in double quotes and returns the number of characters it just printed on the screen.
+ 2
https://code.sololearn.com/cVK9AnFXkzf5/?ref=app
Check my code.
+ 2
How first work ?
0
Ok it is returning number of char but why it is printing on desktop we are just taking it as argument