စံကား

03

Values and kinds

Each value has a kind - integer, decimal number, character or true/false.

A value is a piece of data: the number ၄၂, the letter 'က', the answer "true". Each value has a kind. The kind tells what sort of data the value is and what a program can do with it. Two numbers can be added, but two answers of "true" cannot.

စံကား

Expected output

၄၂
၃.၁၄
က
မှန်
စာ

The kinds

KindReads asHoldsPage
ကိန်းပြည့်"whole number"integers: ၀, ၁၈, -၅Integers
ဒဿမကိန်း"decimal number"numbers with a fraction: ၃.၁၄Decimal numbers
စာလုံး"letter"one character: 'က', 'A'Characters
မှန်မှားတန်ဖိုး"true/false value"မှန် (true) or မမှန် (false)True and false

Text in quotes, such as "စာ", has no kind of its own so far. A program can do nothing with it but print it (see Text in quotes).

The kind matters as soon as a program stores values. The next chapter, Variables, shows how. Each variable is declared with its kind.

Hands on

  • Print one value of each kind.
  • Print ၃ + ၀.၅. Then print 'က' + ၁ and read the error message.

Next: Integers.