Within a computer program, a series of “instructions” directs the computer’s operations.
These instructions, termed statements in programming languages, dictate specific actions.
The subsequent statement directs the compiler to display the text “Hello World” on the screen:
printf(“Hello World!”); |
Ensuring termination of each statement with a semicolon (;) is crucial.
Omitting the semicolon (;) will result in an error, preventing program execution.
printf(“Hello World!”) |
error: expected ‘;’ before ‘return’ |
The majority of C programs consist of numerous statements.
These statements are sequentially executed, adhering to the order in which they are written.
printf(“Hello World!”); printf(“Have a good day!”); return 0; |
In the provided example, three statements are evident:
The initial statement executes first, displaying “Hello World!” on the screen.
Subsequently, the second statement executes, printing “Have a good day!” on the screen.
Finally, the third statement executes, successfully concluding the C program.
As you progress through this tutorial, you’ll delve deeper into statements. For now, ensure you conclude them with a semicolon to prevent errors. Next up: The following chapter will cover techniques for managing output and incorporating new lines to enhance readability. |