Writing Statements

When we write the source code, we called this a statement. Statement is few words or symbol arrange to make one self contain specific instruction. A statement does something, a code that has an effect to your program. That means statement have to complete and make sense.

Complete Statement

When you write something like this :

  • "Print"
  • "Move "
  • "Add 99 to"

It's not complete and computer will not understand what you want. Computer know the word but still cannot do anything. It's not statement. Statement has to know what being done, and what is it being done to.

Example of complete statement :

  • "Print Hello World"
  • "Move the mountain graphic by 5 pixels to right"
  • "Add 99 to current score"

Of course, example above is not in any programming language, it's some informal description. Let us wrote "Add 99 to current score" to some programming language.

COBOL :

ADD 99 to score

AppleScript :

set score to score + 99

Swift, Ruby, and Phyton :

 score  = score + 99

Same intention, same problem, but different syntax. It's all complete statement.

There are some words that can be classified as sentences, like 'Quit' or 'Beep', but most of the time they will need more than one word.

Ending Statements

In many language, having instruction in separate lines is not enough. You must also explicitly end each statement with special character. For example, in Java :

score = score + 99;

It's exactly the same with statement we write before, but ended with semicolon.

results matching ""

    No results matching ""