Explaining Your First C Program
Here's the first C program we wrote:
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
Notice the following line of code:
printf("Hello, World!");In the above code, the printf statement prints the text Hello, World! to the screen.
Remember these important things about printf:
- Everything required for the printing operation is kept inside parentheses
(). - The text to be printed is enclosed within double quotes
"". - Each
printfstatement ends with a semicolon;.
Not following these rules will result in errors and your code will not run successfully.