Statement

A statement is a complete instruction that tells a program to perform an action. It is a line of code that the computer executes.

Why statements are important

Programs are made of statements.

Each statement performs a specific task, such as:

  • Assigning a value

  • Calling a function
  • Making a decision
  • Creating a loop

Without statements, a program cannot run.

 

Simple examples

Assignment statement:

score = 10

This statement assigns the value 10 to the variable score.

 

Function call statement:

print("Hello")

This statement executes a function.

 

Conditional statement:

if (age >= 18) { print("Adult") }

This statement controls program flow.

Statement vs Expression

  • Expression → produces a value
  • Statement → performs an action

Example:

5 + 3 ← expression result = 5 + 3 ← statement

The expression creates a value. The statement uses it to do something.

Types of statements

Common types include:

  • Assignment statement
  • Conditional statement
  • Loop statement
  • Return statement

Programs are built by combining many statements.

Why learning statements matters

Understanding statements helps you:

  • Structure programs correctly
  • Control program behavior
  • Organize logic clearly
  • Avoid syntax errors

Statements are the building blocks of any program.

Simple example

Think of a statement like a command:

“Turn on the light.”  “Open the door.” “Add 5 to the number.”

Each command is a complete action.

Related terms

Source

Simplified from general programming documentation and Wikipedia.

Nach oben scrollen