Curriculum
Course: C basic
Login

Curriculum

C basic

C Introduction

0/1

C Get Started

0/1

C Comments

0/1

C Constants

0/1

C Operators

0/1

C Break and Continue

0/1

C User Input

0/1

C Memory Address

0/1

C Structures

0/1
Text lesson

C Statements

Statements

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:

Example

printf(“Hello World!”);

Ensuring termination of each statement with a semicolon (;) is crucial.

Omitting the semicolon (;) will result in an error, preventing program execution.

Example

printf(“Hello World!”)

error: expected ‘;’ before ‘return’

Many Statements

The majority of C programs consist of numerous statements.

These statements are sequentially executed, adhering to the order in which they are written.

Example

printf(“Hello World!”);
printf(“Have a good day!”);
return 0;

Example explained

In the provided example, three statements are evident:

  • printf(“Hello World!”);
  • printf(“Have a good day!”);
  • return 0;

 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.