In my programming class, I don't understand what the value of printf("World") is (question my prof is asking)? What value does a printf have? He says it is 5, but I don't know why. Thanks.
Because printf()
returns the number of bytes that were output. For "World", that's 5: 5 characters, 5 bytes. Count 'em...
When you're learning a new language, it's always a good idea to read the documentation for the new functions you're learning how to use. If you follow the link above, you'll find the following documented for the return value of printf():
Upon successful completion, the fprintf() and printf() functions shall return the number of bytes transmitted.
If your professor is asking you this question, you'll probably find that this was documented in the class textbook as well. Read it, learn it, love it!
Remember... these are different things: What will printf PRINT. What will printf RETURN.
The function will RETURN "the number of bytes" that it output.
It might PRINT the word "duck" on your screen. ... but it will RETURN the number 4. (It wrote 4 characters.)